WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] query_posts and multiple taxonomies (4 posts)

  1. coopersita
    Member
    Posted 3 years ago #

    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

  2. coopersita
    Member
    Posted 3 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:

    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?

  3. coopersita
    Member
    Posted 3 years ago #

    Never mind, I had a typo...

  4. richarduk
    Member
    Posted 3 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