Conditional statement if no posts to display
-
Hello, I’m am trying to add some code in that if there are no posts to display then a line of text like ‘Sorry no posts to display’ appears.
I’m not very good on the php side of things so any help much appreciated.
My code is –
<div id="mainContent"> <div id="homeNews"> <?php if (have_posts()) : ?> <?php while (have_posts()) : the_post(); ?> <div id="saleContainer"> <div id="salePic"><?php if ( has_post_thumbnail() ) { the_post_thumbnail(); } ?></div> <div id="saleContent"> <h3><?php the_title(); ?></h3> <div class="date"><?php the_time('F jS, Y') ?></div> <?php the_excerpt(); ?> </div> </div> <?php endwhile; ?> <?php endif; ?> </div> </div>
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Conditional statement if no posts to display’ is closed to new replies.