You can run 2 wp_query, get the ids and pass those as the post__in
parameter to a 3rd wp_query. Not efficient but will do the job.
Or you can use a subquery and do it all with just one wp_query. Something like the following:
add_filter( 'posts_where', 'myprefix_posts_where', 10, 2 );
new WP_Query([
'post_status' => 'publish',
'post_type' => array('page', 'my_taxonomy'),
/* do not add taxonomy or parent parameters here */
]);
...
...
remove_filter( 'posts_where', 'myprefix_posts_where', 10, 2 );
function myprefix_posts_where( $where, $query ) {
global $wpdb;
$where .= " AND {$wpdb->posts}.ID IN (
(
SELECT ID
FROM {$wpdb->posts}
WHERE post_type="my_taxonomy"
)
UNION ALL
(
SELECT ID
FROM {$wpdb->posts}
WHERE post_type="page"
AND post_parent = " . post_parent_id ."
)
)";
return $where;
}
Maybe there is a better way to do this but I can’t think of any.