Comment utiliser WP_query avec plusieurs ID de publication?
1 réponses
- votes
Veuillez consulter l'entrée Codexpour les paramètres depublication/pagepour WP_Query()
.
Leparamètre 'p'
prend un seulidentifiant depublication,sousforme d'entier.
Pourtransmettre un tableau demessages,vous devez utiliser 'post__in'
:
$myarray = array(144, 246);
$args = array(
'post_type' => 'ai1ec_event',
'post__in' => $myarray
);
// The Query
$the_query = new WP_Query( $args );
Please reference the Codex entry for post/page parameters for WP_Query()
.
The 'p'
parameter takes a single post ID, as an integer.
To pass an array of posts, you need to use 'post__in'
:
$myarray = array(144, 246);
$args = array(
'post_type' => 'ai1ec_event',
'post__in' => $myarray
);
// The Query
$the_query = new WP_Query( $args );
Je souhaiteinterrogerplusieurspublications avec untableau d'identifiants (remarque:j'interroge untype depublicationpersonnalisé).
Voici ce quej'ai,quine fonctionnepas:
Avez-vous des conseils sur lafaçon deprocéder?