Hide code if no posts are found?
-
So I have this chunk of code in my right sidebar. I want to hise the entire module if there are no posts found instead of displaying “no posts found”. How would I go about doing this? Please incorporate your code into mine below if possible. i really appreciate any assistance you awesome wordpressers can provide!
<div id="popularApps" class="module"> <h3>Popular Sleep Apps</h3> <div class="moduleContent"> <?php $query = array ( 'post_type' => 'affiliates', 'affiliatetype' => 'apps', 'category__in' => $post_categories, 'posts_per_page' => 3 ); ?> <?php $queryObject = new WP_Query($query); ?> <?php if ($queryObject->have_posts()) : while ($queryObject->have_posts()) : $queryObject->the_post(); ?> <div class="entry"><a href="/affiliates/<?php echo basename(get_permalink()); ?>/"><?php echo get_the_post_thumbnail( get_the_ID(), array(43,43)); ?> <p><?php if (strlen($post->post_title) > 24) { echo substr(the_title($before = '', $after = '', FALSE), 0, 24) . '...'; } else { the_title();} ?></p></a> <div class="clear"></div> </div> <?php endwhile; else: ?> <p>No Apps are available at this time</p> <?php endif; ?> <?php wp_reset_query(); ?> </div> <div class="moduleFooter"><a href="/affiliates/apps/">View More</a> <div class="clear"></div> </div> </div>
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Hide code if no posts are found?’ is closed to new replies.