filter custom post type by meta key in dashboard

I’m looking for a way to expand e customize more this topic

How to filter post listing (in WP dashboard posts listing) using a custom field (search functionality)?

Read More

I’ve a custom post type in the dashboard i’ve managed to have a small search box with a fixed search function to search a specific meta key. The things is that the search form appears on all the /edit.php pages while i need it only in the specific custom post type edit.php page.

I tried with

if (isset($_GET['post_type']) && $_GET['post_type'] == 'product')

but it doesn’t seem to work.

Related posts

Leave a Reply

1 comment

  1. I’m assuming you’ve used the method in the question linked to and are using the restrict_manage_posts filter.

     add_action( 'restrict_manage_posts', 'my_search_box' );
     function my_search_box() {
         // only add search box on desired custom post_type listings
         global $typenow;
         if ($typenow == 'product') {
           //On custom post type 'product' admin page.
           //Add code for search box here
         }
      }