I'm trying to get a piece of code to filter out tags and categories when it generates its list. Right now it generates all posts by most recent (although it's a little buggy so if someone knows a better piece of code to use with ajax load more, I'm all ears.
Here's the code:
<div class="mcol-posts ajax-posts">
<?php
//BLOG POSTS
$postsPerPage = 5;
$args = array(
'posts_per_page' => $postsPerPage
$loop = new WP_Query($args);
while ($loop->have_posts()) : $loop->the_post();
get_template_part( 'template-parts/content', 'excerpt' );
endwhile;
wp_reset_postdata();
?>
</div>
I want to add something like this (could be different, but this is what I'm working with right now), in order to exclude any posts with tags or categories I don't want. It would be ideal to exclude more than one tag and more than one category, or to NULL either/both if not needed.
if ($cat_not_in) {
$args['category__not_in'] = array($cat_not_in);
}
if ($tag_not_in) {
$args['tag__not_in'] = array($tag_not_in);
}