Forums

Showing category pages even when there are no entries (12 posts)

  1. buskerdog
    Member
    Posted 3 years ago #

    I've just added a lot of new categories to a fairly complex blog and want all the catgory pages to appear even if they don't have any entries yet. (I'll use an if...else to put some slug text on the pages that have no entries). How can I tell it to show category pages for cats with no posts?

  2. estjohn
    Member
    Posted 3 years ago #

    By changing the arguments for <?php wp_list_cats('arguments'); ?>

    http://codex.wordpress.org/Template_Tags/wp_list_cats

  3. Chris_K
    Administrator
    Posted 3 years ago #

    optionall, unfortunately, doesn't seem to work since WP1.5.

    I see a note there that says it'll be back and function with 2.1 though.

  4. Kafkaesqui
    Moderator
    Posted 3 years ago #

    Handy, I believe what's needed here is the hide_empty parameter.

  5. Chris_K
    Administrator
    Posted 3 years ago #

    Ah. Doh. For some reason I ASSumed that optional precluded hide_empty!

  6. Kafkaesqui
    Moderator
    Posted 3 years ago #

    You no doubt assumed it because that's what the Default Usage example stuff on the Codex page claims. Not sure why, but easily fixed...

  7. buskerdog
    Member
    Posted 3 years ago #

    I didn't explain properly (although thanks for that info)

    I'm not using WP_list_cats for this blog because the menu structure is convoluted and carried over from a different pre-WP site. Basically the menus are hard coded in HTML. I know, I know, it's a mess. Basically what I need aren't the lists to list all cats (I don't think I'm doing any dynamic listing anywhere) but for the actual category pages to appear. Right now if I direct my browser to http://www.domain.com/category/mycat and mycat doesn't have any posts I just get the 404 page. I want it to build the page and then just not list any posts.

  8. estjohn
    Member
    Posted 3 years ago #

    It would help if I could see what you mean on the site.. Im a visual type ;) Wanna share the url?

  9. Kafkaesqui
    Moderator
    Posted 3 years ago #

    Or at the very least, what your category template is doing, internally. Apparently it passes off to the 404 page (or more likely, provides a 404-like response).

  10. buskerdog
    Member
    Posted 3 years ago #

    Ok but please don't quote the actual URL. (thinking of Google) I also hesitated to post it because the site is such a mess of code styles that it doesn't validate. Updating the code to the modern era is a project I need to save for a really rainy day.

    Here's the main page: http://tinyurl.com/j6fxn

    And here's a cat (category/africa) that I want to show up with no entries but that doesn't show up: http://tinyurl.com/f9taw
    I tried putting a dummy post in an africa subcat earlier and the page appeared.

  11. buskerdog
    Member
    Posted 3 years ago #

    Also, there's nothing in my category template or my header that passes the user off to the 404 page when there are no posts. Here's what I have in the category.php:
    <?php if (have_posts()) : ?>

    stuff

    <?php else: ?>
    <div class="post">There are no entries in this category yet.</div>
    <?php endif; ?>

    It must be happening somewhere in some WP file...

  12. buskerdog
    Member
    Posted 3 years ago #

    Found something. In wp-includes/classes.php under function handle_404() if I comment out
    $wp_query->set_404();

    it doesn't send the category to 404. The only downside that I can see is that it does the same thing for any category/XXXXX url (ie fake category urls) but then is that really a problem?

Topic Closed

This topic has been closed to new replies.

About this Topic