iwtech.ru
iwtech.ru

Reputation: 39

wordpress query post - several post types and several taxonomies

Folks, Kindly help me. Have tried different ways, but no effect still.
Have several post types in WordPress 3 : clips, events, albums and posts (wordpress default) And several custom taxonomies artists, values say "Smith", "Jones" and "Gordon Jeffrey Kensingtor III jr." (or id 12, 17 and 22)
How can I query all posts of listed type where at least one artist is attached?

$args = array (
    'artists' => array('Smith', 'Jones', 'Gordon Jeffrey Kensingtor III jr.'),
    'post_type' => array('posts', 'clips, 'albums', 'events')
);
$related = new WP_QUERY($args);

It doesn't work. What am I doing wrong? Thank you very much.

Upvotes: 0

Views: 72

Answers (1)

The Alpha
The Alpha

Reputation: 146191

You mat try this

$args = array(
    'post_type' => array('post', 'clips', 'albums', 'events'),
    'tax_query' => array(
         array(
             'taxonomy' => 'artists',
             'field' => 'slug',
             'terms' => array('Smith', 'Jones', 'Gordon Jeffrey Kensingtor III jr.')
         )
    )
);
$related = new WP_Query( $args );

Upvotes: 1

Related Questions