Support » Fixing WordPress » Assign Custom List Type to Custom Post Type

  • I have a custom post type where the ‘filter by post date’ does not make sense. Posts by default use WP_List_Table which calls extra_tablenav() from display_tablenav() without any filters (that I can see) to stop this behaviour.

    Would it be possible to extend the class to rework display_tablenav() and the make WP use that list table instead? If so, where do I start this?

    Ideally I’d be able to add some headers in there as well as remove the date filter.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Tom,

    One way of doing it is to “hide” that filter (with CSS) or remove it with JS. Indeed, you can easily add an extra class to the body with ‘admin_body_class’ filter (depending on the $pagenow and $post_type global vars for example) to only target your CPT list.

    To add one or more filters after those included by WordPress, you can use the ‘restrict_manage_posts’ action.

    Unfortunately, I think that John is right on that, you cannot extend the list table classes for now.

    Hope that helps.

    Thanks Lionel

    I’ve hidden the filter as follows:


    add_filter( 'admin_body_class', 'tcb_admin_body_class' );
    function tcb_admin_body_class( $classes ){
      $screen = get_current_screen();
      if( is_array($classes) ) :
        $classes[] = $screen->post_type;
      else :
        $classes .= ' ' . $screen->post_type;
      return $classes;

    jQuery(' .actions:nth-child(1)').hide();

    Unfortunately, output from the ‘restrict_manage_posts’ action also gets hidden by the above code. Ho hum.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Assign Custom List Type to Custom Post Type’ is closed to new replies.