reordering categories ? (22 posts)

  1. chuckblue
    Posted 10 years ago #

    Searched and couldn't find anything.

    They are presently ordered by ID number, I want to reorder them alphabetically.


    Is there an easy way to do this ?


  2. Kafkaesqui

    Posted 10 years ago #

  3. chuckblue
    Posted 10 years ago #

    Hmm. Wouldn't sort_column be it ? that sorts on ID or name.

    and set sort_order to 'desc' would get it alphabetized ?

    I'm not a php/database person.

  4. Kafkaesqui

    Posted 10 years ago #

    You jumped the gun on my edit. ;) Just set 'sort_column' to name.

  5. chuckblue
    Posted 10 years ago #

    No problem.

    As tired as I am, I'm surprised I caught it at all.


    I couldn't find list_cats in index.php, and there isn't a templte.php

    Where is it ?

    I'm using 1.2

  6. Kafkaesqui

    Posted 10 years ago #

    No wp_list_cats either?

    Shouldn't be too far down from <div id="menu">, towards the end of index.php.

  7. chuckblue
    Posted 10 years ago #

    got wp_list_cats();

    edit: got it.

    added 'sort_column=name' in the () above.

    works now.

  8. davincim
    Posted 10 years ago #

    I'm trying to piece this together, but I'm missing something.

    I reviewed both links in the codex referenced above, but I don't understand how to implement the parameters.

    What I'm wanting to do is:

    a) sort my category list alphabetically
    b) have the number of posts within each category appear in ( )'s next to the category name

    I've tried:

    <?php list_cats(); ?> and,

    <?php list_cats(FALSE, ' ', 'name'); ?>; and,

    <?php wp_list_cats('arguments'); ?>

    all of which are examples in the codex. The results: no change. I made the changes in my sidebar.php. I'm using WP v1.5.

    Any help is very much appreciated. :)

  9. oriecat
    Posted 10 years ago #

    I've got mine in alpha and showing the # of posts (I'm also excluding 2, so you would need to get rid of that part).

    Mine says:
    <?php wp_list_cats('sort_column=name&optioncount=1&exclude=8,10'); ?>

  10. davincim
    Posted 10 years ago #

    Thanks, oriecat. So I entered

    <?php wp_list_cats('sort_column=name&optioncount=1'); ?>

    into my sidebar taking into account the exlusion part and it's still having no affect.

    Two things:
    1. According to the codex (http://codex.wordpress.org/Template_Tags/wp_list_cats) it defines "optioncount" as not displaying the count of posts in each category. So could you help me understand what the value you had in there (1) does?

    2. I didn't have this problem with Kubrick; I noticed it when I changed to Blix. I'm not blaming Blix, just pointing this out in case it might spark an idea for anyone reading this. Maybe it's doing something that's different than the way Kubrick is doing it. Just guessing, but inexperienced with php as I am, I don't see things the way a php expert might see them (yet). ;)

    Here's my test blog where I'm trying things out: http://familywebwatch.com/blog_test/

    EDIT: Oh and btw, did try <?php wp_list_cats('sort_column=name'); ?>, but no change either. :(

  11. oriecat
    Posted 10 years ago #

    On question 1, the default behavior for the optioncount is off, or zero, so the 1 is to turn it on.

    I just copied my code directly from the first example on the wp_list_cats codex page, changing my excludes. It seems very strange that it wouldn't work for you! I don't know if it would make a difference, but it does show it enclosed in ul tags (and mine is too) did you do that?

  12. davincim
    Posted 10 years ago #

    Strange indeed. The code in my sidebar.php is

    <h2><em>Posts by Category</em></h2>
    <ul class="categories">
    <?php wp_list_cats('sort_column=name'); ?>

    If I understand your last question correctly, the code is within ul tags. Could it be that there are no li tags in the code above?

    <ul class="categories">
    <li><a href="http://familywebwatch.com/blog_test/category/general/" title="View all posts filed under General">General</a></li>
    <li><a href="http://familywebwatch.com/blog_test/category/parents/" title="View all posts filed under Parents">Parents</a></li>
    <li><a href="http://familywebwatch.com/blog_test/category/teens/" title="View all posts filed under Teens">Teens</a></li>
    <li><a href="http://familywebwatch.com/blog_test/category/sexual-predators/" title="View all posts filed under Sexual Predators">Sexual Predators</a></li>
    <li><a href="http://familywebwatch.com/blog_test/category/identity-theft/" title="View all posts filed under Identity Theft">Identity Theft</a></li>
    <li><a href="http://familywebwatch.com/blog_test/category/netiquette/" title="View all posts filed under Netiquette">Netiquette</a></li>
    <li><a href="http://familywebwatch.com/blog_test/category/internet-safety/" title="View all posts filed under Internet Safety">Internet Safety</a></li>
    <li><a href="http://familywebwatch.com/blog_test/category/kids/" title="View all posts filed under Kids">Kids</a>

  13. oriecat
    Posted 10 years ago #

    The li's are added by the tag itself.

    I dunno :( What if you remove your class=categories, so it is just the ul? I'm grasping here

  14. Davepar
    Posted 10 years ago #

    I believe it's a bug. Check out this post: http://wordpress.org/support/topic.php?id=28667#post-161194.

  15. davincim
    Posted 10 years ago #

    Man, this is frustrating. :( I tried removing the class=categories, but no change.

    I'm grasping, too, but I'm wondering if this has something to do with "Pages" not working either. I could create pages with no problem, but they just wouldn't show up in the "Pages" section in my sidebar. I was pointed to http://mosquito.wordpress.org/bug_view_advanced_page.php?bug_id=927 where it describes this in more detail. I haven't tried making the change it suggests, and I can't say for sure that it's even related. However, I'm good at brainstorming. ;)

    Thanks again for your help, oriecat. If you have any other suggestions, I'm open to them, but I'll keep plugging away at it and post back if I find anything new.

  16. Kafkaesqui

    Posted 10 years ago #

    Download this file:


    Use it to replace the one in your wp-includes/ directory. Until you do, there's no way to know if the problem you're having is not due to the bug in the original 1.5 release.

  17. davincim
    Posted 10 years ago #

    Kaf - thanks! I was just about to post some results, but then found your suggestion here.

    In short, it worked! However, the post count for each category is moving to the line below the category name instead of beside it. The code that I'm using is <?php wp_list_cats('sort_column=name&optioncount=1'); ?>

    Is it something with that line of code or something else?

  18. Kafkaesqui

    Posted 10 years ago #

    Obviously post count should show up next to the category link, and other than the sort_column's value, I'm using the same on my blog with no such problem. I'd probably start looking for something in the css.

  19. davincim
    Posted 10 years ago #

    Yep, found it. Now I know what "display:block" does. ;)

    Cheers Kaf!

  20. oriecat
    Posted 10 years ago #

    I'm glad you got it sorted out! :)

  21. davincim
    Posted 10 years ago #

    Me too. Thanks for your assistance. :)

  22. mkgago
    Posted 9 years ago #

    Is it possible to sort categories by the number of posts within them, so that the categories with the most posts is up at the top?

Topic Closed

This topic has been closed to new replies.

About this Topic


No tags yet.