Remove All, Published and Trashed Post Views from WordPress

add_action( 'views_edit-post', 'child_remove_some_post_views' );
/**
 * Remove All, Published and Trashed posts views.
 *
 * Requires WP 3.1+.
 * @param array $views
 * @return array 
 */
function child_remove_some_post_views( $views ) {
	unset($views['all']);
	unset($views['publish']);
	unset($views['trash']);
	return $views;
}

Similar views can be edited by hooking into 'views_' . $screen->id where $screen is the global $current_screen (or get_current_screen()). Draft, Pending, Mine and Sticky could all be removed in a similar manner.

Comments

  1. justin says:

    can you remove on the post count and not the name itself? If so how would i go about doing that?

  2. eugene says:

    Hi Gary, can we remove those views in Custom Post Type edit screen ? I’ve tried with that but failed…

  3. eugene says:

    something like this, but it did not work :

    if( get_post_type() === ‘movie’ ) {
    unset($views['all']);
    unset($views['publish']);
    unset($views['trash']);
    }

    return $views;

  4. I suspect you could leave my demo function the same, but change the hook it is applied to – instead of views_edit-post, try views_edit-movie for instance.

  5. eugene says:

    Thanks for your quick reply! It woks like a charm, yesss

Speak Your Mind

*