WordPress.org

Support

Support » Themes and Templates » [Resolved] category template – what to display when there are no posts

[Resolved] category template – what to display when there are no posts

  • 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!

    -Sara

Viewing 3 replies - 1 through 3 (of 3 total)
  • 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?

    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?

    Thanks!

    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 } ?>

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘[Resolved] category template – what to display when there are no posts’ is closed to new replies.
Skip to toolbar