I've used code to remove other elements on the bar where the "Filter" button is displayed, but I can't find a way to (ideally) disable or (less ideally) hide this button.
I've used code to remove other elements on the bar where the "Filter" button is displayed, but I can't find a way to (ideally) disable or (less ideally) hide this button.
Share Improve this question asked Jul 18, 2021 at 6:26 fakeguybrushthreepwoodfakeguybrushthreepwood 2111 gold badge5 silver badges15 bronze badges 3 |1 Answer
Reset to default 0There isn't a filter or an action in order to prevent this BUT
Wordpress adds the post-type slug of the current page post type to the classes in body tag. Also the slug of the page, in your case .edit-php
If you want to do it with css (replace {your_post_type} with your post type)
body.post-type-{your_post_type}.edit-php #post-query-submit{
display: none!important;
}
ie: for page post type:
body.post-type-page.edit-php #post-query-submit{
display: none!important;
}
If you want to do it in javascript:
add_action( 'admin_footer', function(){
echo <<<EOF
<script>
jQuery(document).ready(function(){
jQuery('body.post-type-{your_post_type}.edit-php #post-query-submit').remove();
});
</script>
EOF;
} );
Remember to replace {your_post_type} with the slug of your custom post type.
#posts-filter .tablenav .actions { display: none; }
, or use JS to remove the "actions" div or just that button. But are you sure you want to disable the ability to filter the posts via that div/button? – Sally CJ Commented Jul 18, 2021 at 7:00