• Resolved mindkil

    (@mindkil)


    I want to have a check if posts with some Category exist, and then list the contents of it on a page, and if not to make some simple message (like: No current posts in this category). How to make this conditional statement? I have a loop showing the posts like this:

    <?php
    $myposts = get_posts('posts_per_page=-1&category=9');
    foreach($myposts as $post) :
      setup_postdata($post); ?>
    
    <div class="art-PostContent">
     <h3 class="art-PostHeader"> <?php  the_title(); ?> </h3>
     <?php the_content(); ?>
    
    </div>
    
    <?php endforeach;  ?>
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Checking if posts exist in category when listing’ is closed to new replies.