Query Multiple Taxominies Across Multiple Post type’s

i have searched and found some aprroved answers to similer questions
but nothing i could make work or something exactly like my issue…

i have 5 custom post type…
each one have its own taxmonies and inside all of them i have created
a category called specials… i need to pull all posts marked with
this category from all post types…

Read More

i have currently stuck starring at this code which doesent work..

$itemsAmount = of_get_option('sg_specials_amount');

query_posts(array( 
    'post_type' => array('engagement_ring', 'wedding_ring', 'pendants', 'earrings', 'bracelets'),
    'posts_per_page' => $itemsAmount,                       
    'tax_query' => array(
        'relation' => 'AND',
        array(
            'taxonomy' => 'wedding_cat',
            'field' => 'slug',
            'terms' => 'specials'
        ),
        array(
            'taxonomy' => 'engagement_cat',
            'field' => 'slug',
            'terms' => 'specials'
        )
    ),
    'orderby' => 'rand',
    'paged' => get_query_var('paged')                       
) );  

(in this example code trying to pull just from two taxomonies but would use five)
.

if relevant then beneath the code i pasted here i have
the loop which can be found here: http://pastebin.com/ds4kFptq

Would appreciate your help
Sagive.

Related posts

Leave a Reply

1 comment

  1. At a glance, I would guess that the problem is your use of

    'relation' => 'AND'
    

    Using AND means that you will only return items that fall into all of the taxonomy terms. If you want to return items have any of the taxonomy items, change it to

    'relation' => 'OR'
    

    If that “doesn’t work”, please provide more details about what “it doesn’t work” means 🙂