I wonder if I can use WP_Query()
with multiple slug like p => array(1,2,3)
I have tried using pagename => array('accommodation','activities','restaurant')
but pagename expects a string and doesn't accept arrays.
How do I Query multiple page using the page slug?
I wonder if I can use WP_Query()
with multiple slug like p => array(1,2,3)
I have tried using pagename => array('accommodation','activities','restaurant')
but pagename expects a string and doesn't accept arrays.
How do I Query multiple page using the page slug?
For multiple slugs, you can use post_name__in
:
new WP_Query( array(
'post_name__in' => array( 'accommodation','activities','restaurant' ),
) );
For multiple post IDs, you can use post__in
:
new WP_Query( array(
'post__in' => array( 1, 2, 3 ),
) );
You can check the Codex for more details.