WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Displaying categories alphabetically (3 posts)

  1. Palagrin
    Member
    Posted 3 years ago #

    I'm developing a wordpress site (blog.thirstforfiction.com), and one of the essential things is that I can display the subcategories of a category alphabetically. Currently, I can display the subcategories using this code:

    <?php if (is_category()) {
      $this_category = get_category($cat);
      if (get_category_children($this_category->cat_ID) != "") {
        echo "<h2>Subcategories</h2>";
        echo "<ul>";
        wp_list_categories('orderby=id&show_count=0&title_li=
    &use_desc_for_title=1&child_of='.$this_category->cat_ID);
        echo "</ul>";
      }
    }
    ?>

    But I don't know how to display the results alphabetically. I've tried various tutorials, but my PHP knowledge is incredibly shallow.

    Anyone know how to edit the above code to display results alphabetically?

    PS: It's specifically http://blog.thirstforfiction.com/authors that I want this for.

    Thanks.

  2. MULTIDOTS
    Member
    Posted 3 years ago #

    Hello Palagrin,
    you can display categories alphabetically using this code
    wp_list_categories('orderby=name&order=asc')

    or you can refer the wp_list_categories

    Please ask if any difficulty in this

  3. Palagrin
    Member
    Posted 3 years ago #

    Thankyou very much, I didn't realise it was so simple.

Topic Closed

This topic has been closed to new replies.

About this Topic