Complex Category selection as per user input

The query you need to use is not so complicated as you basically just what to get posts from only certain taxonomies. You are right that you should use the tax_query.

The first thing that you should do is collate all your category IDs in only one array as there is no need for multiple ones since you are only using the IN condition (that means posts that belong to at least one category in the list). It makes code error-prone and slow to have multiple tax queries when one would suffice.

The problem with your query is that you are using a AND relation that is never true in your case (ie. you don’t have a post that is at the same time in categories 108 or 109, and in categories 112 or 113).

So I would suggest you use WP_Query args like so:

$args = array(
    'post_type' => 'post',
    'tax_query' => array(
        array(
            'taxonomy' => 'category',
            'field'    => 'term_id',
            'terms'    => array( 108, 109, 112, 113, 114, 115, 116, 117, 118, 102, 103 ),
            'operator' => 'IN',
        ),
    ),
);

I understand that you have a multi-step logic to select the posts to display in certain categories. I have given it some thought and it would be quite cumbersome to implement this logic in a tax query through various AND/OR relationships. I think you should do all of the category selection in PHP and end up with an array of category ids that you would use like above. This will allow you to separate your logic from the actual posts selection.

deneme bonusu veren sitelerbahis casinomakrobetceltabetpinbahispolobetpolobet girişpinbahis girişmakrobet girişpulibet girişmobilbahis girişkolaybet giriş