0

I want to show all blog categories that aren't of type gallery. My code almost works but if I have 2 posts in the same category the category is shown twice ie:

If I create a category called 'news' and add 2 non-gallery posts, it shows up as:

news 
news

Instead of just:

news

<?php 
   $galleryPosts = new WP_Query(array(
       'post_type' => 'post',
       'order' => 'ASC'
   ));
   ?>
<?php if ( $galleryPosts->have_posts() ) : ?>
<?php while ( $galleryPosts->have_posts() ) : $galleryPosts->the_post(); ?>
<?php if(!has_post_format('gallery')) {
   the_category();
   }

   ?>
<?php endwhile; ?>
<?php endif; ?>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.