WordPress.org

Support

Support » How-To and Troubleshooting » [Resolved] query_posts and multiple taxonomies

[Resolved] query_posts and multiple taxonomies

  • coopersita
    Member

    @coopersita

    Hi,

    I have a site that uses custom post types, and custom taxonomies, and I’m having problems retrieving posts that have one taxonomy or the other:

    query_posts(array( 'project_type' => array('Films', 'Animation'), 'post_type' => 'projects', 'showposts' => 99 ));

    I want to show posts with Films or Animation as their taxonomy, but I get back nothing.

    Also, do I need to specify in query_posts to just show published posts, or is that a given?

    Thanks

Viewing 3 replies - 1 through 3 (of 3 total)
  • coopersita
    Member

    @coopersita

    I found the “Query Multiple Taxonomies” plugin, but my problem now is that it’s doing an OR search on all fields, so the following:

    query_posts('project_type=Films,Animation&post_type=projects&showposts=99');

    Is also pulling posts from the post_type mediaentries who have a project type of Films and Animation…

    I guess I could create a separtae taxonomy for projects and mediaentries, but is there a way to convey whether it’s an AND or an OR in the search query?

    coopersita
    Member

    @coopersita

    Never mind, I had a typo…

    For anyone finding this from Google who wants to show all custom post types on a page:

    <?php   $new_loop= new WP_Query(array('order' => DESC,  'post_type' => array('post', 'review'), 'posts_per_page' => 10, 'paged' =>$paged));?>
    <?php if ($new_loop->have_posts()) :  while ($new_loop->have_posts()) : $new_loop->the_post(); ?>

    where review and post are the post types.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘[Resolved] query_posts and multiple taxonomies’ is closed to new replies.