WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want the defult CPT listing to include not all posts but only some, according to a specific taxonomy. is there a way to do that ?

share|improve this question
up vote 1 down vote accepted

This trick should help you...

add_action('pre_get_posts', 'filter_posts_list');
function filter_posts_list($query)
    //$pagenow holds the name of the current page being viewed
    global $pagenow;
    $post_type = $query->get('post_type');

    //Check the post type and whether its the list page, then set the taxonomy
    if($post_type == 'my_cpt' && 'edit.php' == $pagenow)
        //global $query's set() method for setting the taxonomy
        $query->set('my_taxonomy', 'my_taxonomy_value');

You can use any WP_Query parameters with the set method to modify this solution. For a detailed explanation, hit this.

share|improve this answer
one error in the if up there. couldn't edit coz it's just one char – hannit cohen Mar 7 '12 at 14:09
Ohh... typo... fixed it! – Rutwick Gangurde Mar 7 '12 at 14:17

Your Answer


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.