admin管理员组文章数量:1193159
On a custom post type, I want to remove the filters that show up on /edit.php (where all of the posts are listed out).
I have a custom taxonomy that shows up as a filter that I WANT to keep, but I want to REMOVE the 'Show all dates' and 'View all categories' filters.
Any ideas?
On a custom post type, I want to remove the filters that show up on /edit.php (where all of the posts are listed out).
I have a custom taxonomy that shows up as a filter that I WANT to keep, but I want to REMOVE the 'Show all dates' and 'View all categories' filters.
Any ideas?
Share Improve this question asked Dec 11, 2011 at 2:56 katemerartkatemerart 1991 gold badge4 silver badges7 bronze badges4 Answers
Reset to default 5This is a very similar question to the one you posted here: How to HIDE everything in PUBLISH metabox except Move to Trash & PUBLISH button Please check my answer. You would simply need to add the IDs of the elements you wish to hide.
You can traverse the DOM to target the elements you need:
#posts-filter .tablenav select[name=m],
#posts-filter .tablenav select[name=cat],
#posts-filter .tablenav #post-query-submit{
display:none;
}
There is a filter for the dropdown dates since WP 3.7.0 (sorry I did not check the others but I assume they also have filters).
The filter is: months_dropdown_results
This example below removed the dates dropdown from the admin pages filter but not for posts.
function remove_date_drop(){
$screen = get_current_screen();
if ( 'page' == $screen->post_type ){
add_filter('months_dropdown_results', '__return_empty_array');
}
}
add_action('admin_head', 'remove_date_drop');
Hiding by css also affect other post/page types. At least I was able to remove Actions for an specific cpt using this hook
add_filter('bulk_actions-edit-mycpt', '__return_empty_array');
Since WordPress 4.2.0, removing the All Dates dropdown filter menu is much easier thanks to the disable_months_dropdown
filter.
To disable the dates filter menu everywhere, use the __return_true
helper:
add_filter('disable_months_dropdown', '__return_true');
To disable the dates filter menu for a specific post_type, use a simple function like this:
add_filter(
'disable_months_dropdown',
function ($disable, $type) {
return $type === 'my_post_type';
},
10,
2,
);
本文标签: How to remove Filters from post admin page
版权声明:本文标题:How to remove Filters from post admin page? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1738475865a2088856.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论