I want to remove the below text links in Edit Post screen:
All (8) | Published (5) | Draft (1) | Pending (2) | Trash (2)
After searching, i found that this can be done by this code here, but sadly it only works with ‘post’ type. I’m failed to make it works with my custom post type:
add_action( 'views_edit-post', 'remove_edit_post_views' );
function remove_edit_post_views( $views ) {
if( get_post_type() === 'movie' ) {
unset($views['all']);
unset($views['publish']);
unset($views['trash']);
}
return $views;
}
What’s wrong with my code ?
Further down on the page you linked to is this comment:
When you’re editing a post, you’re on the “edit-post” screen, so the action you use is
views_edit-post
. If you’re working with a custom post type called “gallery,” the edit screen is “edit-gallery” and you’d hook into theviews_edit-gallery
action.In your case I’d do the following:
This will remove “all”, “publish”, and “trash” from both posts and the custom post type “movie.” Removing these views from other post types is as simple as adding the following line:
Just replace
{post-type-slug}
with the name of your custom post type.I was doing something similar and grabbed this code and realized that “Draft” still showed up, so some testing shows you can just do one line:
This will remove all of them if your goal is to remove the whole line. I’m on WP 3.5 FWIW.