Or ifI understand that you have a multi-step logic to select the internalposts to display in certain categories. I have given it some thought and it would be quite cumbersome to implement this logic preventsin a tax query through various AND/OR relationships. I think you from doing this, one-level deepshould do all of the category selection in PHP and end up with OR relation:
$args = array(
'post_type' => 'post',
'tax_query' => array(
'relation' => 'OR',
array(
'taxonomy' => 'category',
'field' => 'term_id',
'terms' => array( 108, 109 ),
'operator' => 'IN',
),
array(
'taxonomy' => 'category',
'field' => 'term_id',
'terms' => array( 112, 113 ),
'operator' => 'IN',
),
array(
'taxonomy' => 'category',
'field' => 'term_id',
'terms' => array( 114, 115, 116 ),
'operator' => 'IN',
),
array(
'taxonomy' => 'category',
'field' => 'term_id',
'terms' => array( 117, 118 ),
'operator' => 'IN',
),
array(
'taxonomy' => 'category',
'field' => 'term_id',
'terms' => array( 102, 103 ),
'operator' => 'IN',
),
),
);
Let me know how this goesan array of category ids that you would use like above. This will allow you to separate your logic from the actual posts selection.