Search
Close this search box.

How to remove date filter on post type admin pages in WordPress

To remove the date filter on post type admin pages in WordPress, you can use the restrict_manage_posts action hook in your theme’s functions.php file. This hook allows you to customize the filtering options that appear above the list of posts on the post type admin pages.

Here’s an example of how you can use this hook to remove the date filter:

add_action( 'restrict_manage_posts', 'remove_date_filter' );
function remove_date_filter() {
    // Check if the current screen is a post type admin page
    $screen = get_current_screen();
    if ( $screen->post_type != 'your-post-type' ) {
        return;
    }
 
    // Remove the date filter
    add_filter( 'months_dropdown_results', '__return_empty_array' );
}

In this example, you will need to replace “your-post-type” with the slug of the post type that you want to target. This code will remove the date filter from the post type admin pages for the specified post type.

Keep in mind that the restrict_manage_posts action hook may not always be the best solution for removing the date filter, depending on your specific requirements and use case. For example, if you want to remove the date filter from all post type admin pages, you may need to use a different approach.

Share this post

You might also like...

Forum

bbPress for WordPress Review

bbPress is a great plugin for WordPress that offers a powerful forum solution for WordPress websites. It is well-supported, easy to use, and provides great

Read More »

Comment

Your email address will not be published. Required fields are marked *