Basically I have regular Category Listings that include posts WITH tags and posts WITHOUT tags.
I need to modify the loop so that it ONLY includes posts which have one or more tags assigned to them.
Is there a way do this?
Thanks
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It only takes a minute to sign up.
Sign up to join this communityBasically I have regular Category Listings that include posts WITH tags and posts WITHOUT tags.
I need to modify the loop so that it ONLY includes posts which have one or more tags assigned to them.
Is there a way do this?
Thanks
here is an example loop..
you can change the number of tag to exclude based on the amount you want...
<?php
if (have_posts()) : while (have_posts()) : the_post();
// GET THE TAGS OF CURRENT POST IN LOOP AND COUNT THE AMOUNT
$posttags = get_the_tags();
$howmany = count($posttags);
if($howmany > 2) {
?>
<h3><?php the_title(); ?></h3>
<?php the_excerpt(); ?>
<?php
} else {
// do nothing
}
endwhile;
?>
<?php endif; ?>
.
Hope This Helps
Sagive
<?php $posts = query_posts( $query_string . '&orderby=title&order=asc&post_type=glossary' ); ?> <?php if (have_posts()) : while (have_posts()) : the_post(); // GET THE TAGS OF CURRENT POST IN LOOP AND COUNT THE AMOUNT $posttags = get_the_tags(); $howmany = count($posttags); if($howmany > 2) { ?> <div class="cat-posts"> <h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3> <?php the_excerpt(); ?> </div> <?php } else { // } endwhile; ?> <?php endif; ?>