Come utilizzare WP_query con ID multipli di post?
16 dic 2012, 04:18:45
Visualizzazioni: 66.2K
Voti: 24
Voglio interrogare più post con un array di ID (nota: sto interrogando un custom post type).
Ecco quello che ho, che non sta funzionando:
$myarray = array(144, 246);
$args = array(
'post_type' => 'ai1ec_event',
'p' => $myarray
);
// L'interrogazione
$the_query = new WP_Query( $args );
Qualche suggerimento su come farlo?
Tutte le risposte alla domanda
1
0
Per favore fai riferimento alla voce del Codex per i parametri di post/pagina per WP_Query()
.
Il parametro 'p'
accetta un singolo ID di post, come intero.
Per passare un array di post, devi usare 'post__in'
:
$myarray = array(144, 246);
$args = array(
'post_type' => 'ai1ec_event',
'post__in' => $myarray
);
// La Query
$the_query = new WP_Query( $args );

Chip Bennett
55.1K
16 dic 2012 04:28:28
Domande correlate
5
risposte