WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] list_cats changed in v1.5.1 ? (8 posts)

  1. I had this in v1.5.0 and it worked perfectly:

    list_cats(FALSE, '', '', '', '', TRUE, '', TRUE);

    After upgrading, I get this:

    WordPress database error: [Unknown column 'cat_' in 'order clause']
    SELECT cat_ID, cat_name, category_nicename, category_description, category_parent FROM wp_categories WHERE cat_ID > 0 ORDER BY cat_

    Warning: Invalid argument supplied for foreach() in /chroot/www/finalgear.com/html/wordpress/wp-includes/template-functions-category.php on line 304
    * No categories

    Removing the parameters fixes it. Anyone else have this problem?

  2. Seems this was my fault. I needed to specify what to sort by (either ID or name). No idea why I had it as '' before. Stupid me.

    Now using this and it works perfectly. :)

    list_cats(FALSE, '', 'ID', 'asc', 'index.php', TRUE, FALSE, TRUE);

    And now that I think of it, I could probably just use wp_list_cats to avoid having to define all of those parameters. :)

    [edit]

    Yep, wp_list_cats('optioncount=1'); works great. :D

    [/edit]

  3. brianbonner
    Member
    Posted 9 years ago #

    All I did was add this code to my right column.

    <div class="rightsideSection">
    <h4>Categories</h4>
    <ul>
    <?php wp_list_cats('sort_column=name&optioncount=0&hierarchical=1'); ?>
    </ul>
    </div>

    This sorts it in hieraarchical form. Just reverse the 0 and 1 to make it sort by name.

  4. Yeah, I just wanted to turn post counts on: http://www.finalgear.com/ :)

  5. lai
    Member
    Posted 9 years ago #

    To brianbonner:
    I used the following code. The category doesn't show hieraarchical form.

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

    Any idea why?

  6. brianbonner
    Member
    Posted 9 years ago #

    where did you place it? inside the parenthesis the apostrophy looks different in your post, I don't know why. I would like to look at your souce what is the url?

  7. moshu
    Member
    Posted 9 years ago #

    It looks different (here) because s/he didn't use the proper backticks for code:
    <?php wp_list_cats('sort_column=name&optioncount=0&hierarchical=1'); ?>

  8. brianbonner
    Member
    Posted 9 years ago #

    Viper,

    this code
    <div class="rightsideSection">
    <h4>Categories</h4>
    <ul>
    <?php wp_list_cats('sort_column=name&optioncount=1&hierarchical=1'); ?>
    </ul>
    </div>

    Will do what you want for categories. See my blog
    http://uncooperativeblogger.com

    Well it will sort by hierarchy alphabetically and give a post count. If you don't have, or plan to have, sub categories then turn the heiracrhy value off(to zero)

Topic Closed

This topic has been closed to new replies.

About this Topic