It’s not recommended to use query_posts()
, check for example this warning note in the Codex:
This function isn’t meant to be used by plugins or themes. As
explained later, there are better, more performant options to alter
the main query.query_posts()
is overly simplistic and problematic way
to modify main query of a page by replacing it with new instance of
the query. It is inefficient (re-runs SQL queries) and will outright
fail in some circumstances (especially often when dealing with posts
pagination). Any modern WP code should use more reliable methods, like
making use ofpre_get_posts
hook, for this purpose.
Regarding the post parents array, you’re using a wrong parameter. There exists the post_parent__in
parameter that can handle an array input.
So please try this secondary query, instead of your current one:
$query = new WP_Query(
array(
'post_type' => 'page',
'post_parent__in' => array(376, 379),
'orderby' => 'title',
'order' => ASC,
'posts_per_page' => 9999
)
);
You should also consider initializing your variable with $return_string = '';
to avoid the PHP Undefined variable notice when you use the .=
for string concatenation.
Then replace wp_reset_query()
with wp_reset_postdata()
, to reset the $post
variable of the main query.