The simplest solution would be to query all posts using a -1 in place of the 12 in your ‘posts_per_page’ argument of your query. Then use a counter that ticks up if all of the above conditions equal true.
$args = array(
'post_type' => $post_slug,
'posts_per_page' => -1,
'paged' => 1,
'post_status' => 'publish',
);
$topicsHub = new WP_Query($args);
$post_counter = 0;
<?php while ( $topicsHub->have_posts() ) : $topicsHub->the_post();
// if the $post_counter variable gets above your limit, break from the loop
if ($post_counter >= 12) { break; }
// conditional statements, breaks and continues...
?>
<div class="u-12 u-6@sm u-4@md resource__main-tab--item">
<?php get_template_part('partial/content', 'topics-card'); ?>
</div>
<?php
// increment $post_counter every time the loop gets this far (the above div will have printed)
$post_counter++;
endwhile; ?>
However, if you wanted to query only the first 12 posts that matched your conditions, take a look at advanced query parameters for WP_Query($args)
. There are tons of IFs, ORs, XORs, etc. that you can use inside of the $args
variable. Just might get super messy and unreadable with the amount of logic you’re using in your while statement, so I’d recommend using the first method.