You have two options:
-
Call get_posts multiple times: one for the parent pages using
post__in => array(2,4)
, and two for the child pages of each parent withpost_parent => 2
andpost_parent => 4
and finally merge all the results into a single array. -
Write directly your SQL query and use
$wpdb->get_results
. See this article for an example. In your case it would be something similar to the following (not tested) code:$query_sql = " SELECT * FROM $wpdb->posts WHERE post_type="products" AND (ID IN (2,4) OR post_parent IN (2,4)) ORDER BY post_date DESC "; $query_result = $wpdb->get_results($query_sql, OBJECT);