Hide loop if less then X in category... (2 posts)

  1. batrikperg
    Posted 3 years ago #

    I'm using a custom page as my startpage (it's a one-page website), wisch is populated with posts from different categories.

    Now, I have this loop:

    <div class="block">
    <ol class="list-text archive">
    	<?php $recent = new WP_Query(); ?>
    	<?php $recent->query('cat=3&showposts=100&offset=3'); ?>
    	<?php while($recent->have_posts()) : $recent->the_post(); ?>
    	         <h3><?php the_title(); ?></h3>
    	       	 <?php the_content(); ?>
    	<?php endwhile; ?>
      <div class="addon">
        <a class="toggle" href="#">More shows</a>

    What I want to do is to hide the whole block if the there is less than 3 posts from this category. Been googling for hours, can't figure out how to do it!

  2. LastForOne
    Posted 3 years ago #

    The total number of posts found matching the current query parameters.

    that should do the trick for you.

    $recent->found_post something like that then compare the value and depending on result show it or not.

Topic Closed

This topic has been closed to new replies.

About this Topic


No tags yet.