Only display, if other posts in category
-
I’m using this code to display all the posts in the current category in an unordered list.
<h2 class="bluebottom"><?php $categories = get_the_category(); foreach($categories as $category) { echo $category->name . ' '; } ?></h2> <ul> <?php global $post; $category = get_the_category($post->ID); $category = $category[0]->cat_ID; $myposts = get_posts(array('numberposts' => 99, 'category__in' => array($category), 'post__not_in' => array($post->ID),'post_status'=>'publish')); foreach($myposts as $post) : setup_postdata($post); ?> <li> <a href="<?php the_permalink(); ?>"> <?php the_title(); ?> </a> </li> <?php endforeach; ?> <?php wp_reset_query(); ?> </ul>
I would like to write an if statement, where the title does not show if there are not other posts in the current category. Could anyone help me with that?
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Only display, if other posts in category’ is closed to new replies.