5

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

1 Answer 1

6

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');
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.