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?
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 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');
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0