Site icon Hip-Hop Website Design and Development

WP_Query displaying all posts, besides from class X, until it is also in Y

I am attempting to point out posts from classes A, B, C, D…and Y, besides X, until posts in X are additionally in Y, then present them with the remaining.

I can conceal class X on it is personal fairly merely:

$args = array(
    'post_type' => 'put up',
    'posts_per_page' => 15,
    'paged' => $paged,
    'cat' => '-X',
);

I’ve tried to mix two loops, one getting all posts excluding X, the opposite getting posts which might be in each X and Y, but it surely does not appear to work:

$EverythingButXLoop_args = array(
    'post_type' => 'put up',
    'cat' => '-X',
);
$EverythingButXLoop = new WP_Query( $EverythingButXLoop_args );

$OnlyXwithYLoop_args = array(
    'post_type' => 'put up',
    'category_name' => 'categoryX+categoryY',
);
$OnlyXwithYLoop = new WP_Query( $OnlyXwithYLoop_args );

$mainLoop_args = array(
    'posts_per_page' => 15,
    'paged' => $paged,
);
$mainLoop = new WP_Query( $mainLoop_args );
$mainLoop->posts = array_merge( $EverythingButXLoop->posts, $OnlyXwithYLoop->posts );

//populate post_count depend for the loop to work appropriately
$mainLoop->post_count = $EverythingButXLoop->post_count + $OnlyXwithYLoop->post_count;

I’ve additionally thought of getting all class ID’s in a var(as an alternative of itemizing each one in all my many different classes) and utilizing it with a class parameter to exclude posts in X…someway, ie. 'cat' => $categoryIDs, 'category__not_in' => 'X' however I feel I am nonetheless simply confronted with the unique drawback: excluding X, besides when in X and Y

Any thought what’s not working with the combining method above, or how I can obtain this one other (higher) manner? Thanks prematurely!