maxelcat
maxelcat

Reputation: 1333

wordpress query for pages with arrays not working

Hi I am trying to get a couple of pages out of wordpress by using a query.

when I do

$query= new WP_Query('page_id=5880');

everything is fine

However,

$query = new WP_Query( array( 'post_type' => 'page', 'page_id' => array( 5880, 5840 ) ) );

produces nothing. What am I missing please?

Upvotes: 0

Views: 599

Answers (1)

Samuel Liew
Samuel Liew

Reputation: 79032

Instead of page_id, it should be post__in:

$query = new WP_Query( array( 'post_type' => 'page', 'post__in' => array( 5880, 5840 ) ) );

See https://codex.wordpress.org/Class_Reference/WP_Query#Post_.26_Page_Parameters

Upvotes: 2

Related Questions