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)?

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.

  • Welcome to WPSE Martino, could you add some code to show us how you added the search box? Cheers! Commented Mar 12, 2012 at 11:05
  • Actually, it's obvious you are following the method in the linked question :D. See posted answer... Commented Mar 12, 2012 at 11:10

1 Answer 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
  • Wow, that was fast. It works, I hacked it a little more to filter it only by a specific meta_key. Could be useful to post the whole code, but I don't know how, I'm new here and the comment section is too small. pastebin.com/A3kSD57v
    – molokom
    Commented Mar 12, 2012 at 11:26
  • No problem! Please remember to mark correct answers by ticking them though :D Commented Mar 12, 2012 at 11:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.