The Support Forums will be in read-only mode for a scheduled maintenance window on 01 September 2016 14:00 UTC - 20:00 UTC. More information.

[resolved] query_posts and multiple taxonomies (4 posts)

  1. coopersita
    Posted 5 years ago #


    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?


  2. coopersita
    Posted 5 years ago #

    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:


    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?

  3. coopersita
    Posted 5 years ago #

    Never mind, I had a typo...

  4. richarduk
    Posted 5 years ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Topic