Query di più custom post types in un singolo loop
Sono consapevole che ci sono diversi altri post che trattano argomenti simili a quello che sto per chiedere.
Ho tre custom post types attivi, oltre ai 'posts'. Voglio eseguire un loop che estragga tutti i post categorizzati sotto una particolare categoria
<?php
$args = array(
'post_type' => 'testimonial',
'posts_per_page' => 1,
'tax_query' => array(
array (
'taxonomy' => 'testimonial_category',
'field' => 'slug',
'terms' => 'home'
)
)
);
$query = new WP_Query( $args );
$postcount = 0;
?>
<?php if ($query->have_posts()) : ?>
<?php while ($query->have_posts()) : $query->the_post(); ?>
<?php $postcount++; ?>
//loop qui
<?php wp_reset_query(); ?>
Questo è il codice che ho al momento, non sono sicuro di come condensarlo per estrarre più tipi di post da una singola categoria.
Basta modificare la parte del post_type
in:
'post_type' => array('testimonial', 'other_post_type', 'another-post-type'),
Supponendo che la tassonomia sia valida per tutti e 3 i tipi di post. Altrimenti dovrai ometterla.
Perché? Puoi passare un array al campo post_type
.

Come faccio a specificare il nome della categoria in cui cercare. 'taxonomy' => 'testimonial_category'

@user2478101 : ^^ Il tuo tax_query
nella domanda sembra corretto, anche se non l'ho testato. Cosa stai cercando di fare diversamente?

Ho una tassonomia in ogni tipo di post con un termine chiamato home. Voglio estrarre qualsiasi post che lo abbia selezionato

Ho tentato questa soluzione, ma non sembra recuperare altri post dai tipi di post personalizzati. query_posts( array( 'post_type' => array('post', 'testimonial', 'casestudy'), 'cat' => 69, 'showposts' => 3 ) );

Per far funzionare questo, la tassonomia deve essere identica per tutti. Per quanto ne so, i termini non possono essere collegati tra tassonomie diverse. http://core.trac.wordpress.org/ticket/12269
