Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I want to be able to customize the WordPress edit posts screen to filter based on a custom field (or whatever).

Unfortunately I'm not sure what filter or hook to use here, and instead of opening the code myself, figured I'd throw the question out here.

Just to be clear, I'm talking about this screen. Essentially I want to be able to add a new "tab" next to Drafts, Pending, etc.

enter image description here

Update After testing this, here's the solution:

add_filter( 'parse_query', 'filter_post_edit_screen' );
function filter_post_edit_screen($query) {
  global $pagenow;

  if (is_admin() && $pagenow=='edit.php'){
        $query->query_vars['category__not_in'] = array(120,9999);
  }
  return $query;
}

That's it. Just paste that into a plugin. Obviously you'd tweak the category IDs or add some more substantial code.

share|improve this question
add comment

2 Answers

up vote 3 down vote accepted

You need a to use a few hooks for that

take a look at mike's answer to a similar question.

Hope this Helps

share|improve this answer
1  
Interesting, that looks like the right answer. I'll test, but I'll mark it correct now. =) –  The How-To Geek Feb 15 '11 at 1:52
add comment

I found a plugin that might be a solution to your problem: http://wordpress.org/extend/plugins/extended-admin-post-filter/installation/
If that doesn't work then I think the only way out is to edit the WP core files (not recommended though) for the Edit Posts View & add a tab which filters posts according to the category or tag. This should work for sure! :)

share|improve this answer
    
Actually I already tested that plugin - it doesn't actually use any hooks, just adds the extra fields in there as drop-downs, since you can already filter with the query string by clicking on a tag or author name. –  The How-To Geek Feb 15 '11 at 1:46
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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