I would like to query some posts(posttype page) by their name. It works perfectly when I query just one post with this args:
$args = array(
'post_type' => 'page',
'name' => "media"
);
I think this should work easy with this args:
$args = array(
'post_type' => 'page',
'name' => array( 'media', 'lms-efront'),
);
But when I have an array of names it doesn't work and I get all pages, so the argument-array has not any effects(post names are correct).
I have no idea why my code doesn't work as it should, do you know what's the problem?
Thanks
name
parameter accepts only one post. To retrieve multiple posts using an array use post_name__in
instead. Reference
$args = array(
'post_type' => 'page',
'post_name__in' => array( 'media', 'lms-efront'),
);