WordPress allows adding descriptions
to Custom Post Types whenever it’s registered. ( register_post_type()
. I would like to output that title on the Admin Landing Page ( View All Post Type ) preferably underneath the title. I’ve looked into /wp-admin/edit.php
but I’m not sure if the filter presented is usable in this case ( and thus it may not be possible to do ).
Line 274 on Trac is where it looks like the actual title gets set. Is is possible / is there a way to filter into it and add my post type description?
1
The filter views_{$this->screen->id}
is fired just after the title of post edit screen has been print to screen, so it’s a safe place to just echo what you want.
So you can simply do:
function post_type_desc( $views ){
$screen = get_current_screen();
$post_type = get_post_type_object($screen->post_type);
if ($post_type->description) {
printf('<h4>%s</h4>', esc_html($post_type->description)); // echo
}
return $views; // return original input unchanged
}
add_filter("views_edit-POST_TYPE_HERE", 'post_type_desc');