• I want the “Uncategorized posts” link to display in a different font, so I’m calling wp_list_cats twice, the second time excluding everything except the “Uncategorized Posts”. When I do this, though, the count is always zero. Any ideas why? Is there some pointer I have to manually rewind or something? Here’s my code:

    • Post Categories:
      <?php wp_list_cats('sort_column=name&optioncount=1&hierarchical=1&hide_empty=0&exclude=1, 3'); ?>
      <div class="faint">
      <?php wp_list_cats('optioncount=1&hide_empty=0&exclude=2,3,4,5,6,7,8,9,10,11,12,13,14,15'); ?>
      </div>
Viewing 10 replies - 1 through 10 (of 10 total)
  • Thread Starter loneboat

    (@loneboat)

    P.S. Any way I could’ve posted that code more nicely? It came out pretty ugly…

    Thread Starter loneboat

    (@loneboat)

    Like this:
    <ul>
    <li><strong>Post Categories:</strong>
    <ul>
    <?php wp_list_cats('sort_column=name
    &optioncount=1
    &hierarchical=1
    &hide_empty=0
    &exclude=1, 3'); ?>
    </ul>
    <ul>
    <div class="faint">
    <?php wp_list_cats('optioncount=1
    &hide_empty=0
    &exclude=2,3,4,5,6,7,8,9,10,11,12,13,14,15'); ?>
    </div>
    </ul>
    </li>
    </ul>

    Are there any children of your Uncategorized category? What happens if you replace the exclude list with &child_of=0 ?

    Thread Starter loneboat

    (@loneboat)

    There are no children. If I make the replacement with “0”, I get a full list of all the categories, not just the uncategorized one. My uncategorized posts category has an id of “1”, so I also tried replacint with a value of “1”, and the tag output nothing.

    Thread Starter loneboat

    (@loneboat)

    Hmmm, now that I’m playing around with it, it seems like this is a general rule: Once I have excluded a category in wp_list_cats, then in any subsequent calls to wp_list_cats, the post-count will always be zero for that category. Is this a known bug?

    On my test blog, I did this:
    <?php
    wp_list_cats('sort_column=name
    &optioncount=1
    &hierarchical=0
    &child_of=1');
    ?>

    And it appears to have worked.

    It might be a bug. list_cats() attempts to use a cache of categories; so suppressing some categories might negatively affect the cache.

    Maybe try showing your Uncategorized category first, using my example above?

    Thread Starter loneboat

    (@loneboat)

    Strange, when I use that code it gives me a list of all of my categories. Note however that there are no “child_of” categories under category “1” (no subcategories).

    Thread Starter loneboat

    (@loneboat)

    For me to list the uncategorized posts FIRST I would have to either (1) set up a sub-category under “Uncategorized posts” and refer to that category using “child_of” or (2) exclude all of the normal categories, in which case I would no longer get the counts for THOSE categories…

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘“Uncategorized Posts” always shows zero count…’ is closed to new replies.