Exclude category and post from loop in custom category.php

So I created a custom category.php where I have the following loop:

<div id=”category__product-grid” class=”row”>
<?php

// The Loop
while ( have_posts() ) : the_post(); ?>

<div class=”col-md-4 col-product-item”>
<a href=”<?php the_permalink() ?>” rel=”bookmark” title=”<?php the_title_attribute(); ?>”><div class=”cat__featured-img”><?php the_post_thumbnail(); ?></div></a>
<h2><a href=”<?php the_permalink() ?>” rel=”bookmark” title=”<?php the_title_attribute(); ?>”><?php the_title(); ?></a></h2>
</div>

<?php endwhile;

else: ?>
<p>Sorry, no posts matched your criteria.</p>
</div>

I broke my head trying to understand how can I exclude the needed categories from this loop and the required posts as well. Would appreciate any help!

Read more here:: Exclude category and post from loop in custom category.php

Leave a Reply

Your email address will not be published. Required fields are marked *