[resolved] category template - what to display when there are no posts (4 posts)

  1. scormeny
    Posted 10 years ago #

    I am working on a client site where we have a category for future events, using the ec3 plugin to manage the event list.

    On the category page, I would like to have a single sentence that says "there are no upcoming events at this time - check back soon" if there are no posts to list.

    Can I edit the Loop to make this happen? I am not a programmer and the "while" structure is flummoxing me.

    You can see what I've currently got online (tho the site is under construction) at http://www.mikesouthern.com/wp/?cat=2

    Thanks for advice!


  2. moshu
    Posted 10 years ago #

    Excluded it from showing up in the menu if it's empty (=no posts). There is a parameter in the template tag for displaying the categories in the menu to not show if empty.
    Wouldn't that work?

  3. scormeny
    Posted 10 years ago #

    Moshu, that's not at all what I'm looking for, but I appreciate your kind work in responding.

    I am not trying to remove the category from the sidebar.

    Rather, when a category is empty, the page FOR THAT CATEGORY needs to say something, rather than being blank. It needs to say, "There are no posts in this category," or something similar.

    That's what I need -- I think a look at my link will make it clear why, but if not, just know that I'm not looking to do anything other than have alternative text on the category page for when there are no posts.

    So, any thoughts, anyone?


  4. scormeny
    Posted 10 years ago #

    I was able to fix this myself. I added the following code to my category template, above the loop.

    <?php if ( is_category(2) && !have_posts() ) { ?>
    <i>There are no classes currently scheduled.</i>
    <?php } ?>

Topic Closed

This topic has been closed to new replies.

About this Topic