
Remove Specific Categories From The Loop WordPress
July 1, 2021
Sometimes you need to remove a category from your loop. Maybe it’s because that item has been removed, or there is some other reason for removing the data points associated with this particular topic; fortunately, R makes “del” easy to use and understand! The trick here will be opening up our code block so we can make sure cat -3 parameter matches the ID of whatever thing in question needs removal (e.g., if category ID is 1 then replace 3 with 1). Remember: commas are used as separators when deleting more than one variable at once (example. cat=-1,-2, -3,-4,-5
).
<?php query_posts('cat=-3'); ?>
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
<h3></h3>
<p><?php the_time('F jS, Y') ?></p>
<?php the_content(); ?>
<?php endwhile; ?>
Posted in Tutorials