WordPress.org

Ready to get started?Download WordPress

Forums

alphabetizing caegories by last name but displaying full name? (4 posts)

  1. buskerdog
    Member
    Posted 7 years ago #

    The problem with the following wp_list_cats is obvious: http://tinyurl.com/y466pe
    J comes before C. How can I alphabetize these cats by last name? Ideally I'd make the category names just the last names and display the Cat Descriptions, where I'd put the full names. But I can't get that to work.

    Or I'd name the categories with the URL to an image like 'images/lastname_thumb.jpg' but I can't figure out a way to make that work either (I'd need to nest each cat name in an img tag to get that to work.)

    I'd actually prefer the second since I'd like to use custom icons for each category.

    Any ideas?

  2. MichaelH
    Member
    Posted 7 years ago #

    The template tag, wp_list_cats, only allows you access to sort_columns ID or name.

    Now this is funcky, but if you aren't constantly adding new Categories you might try it.

    Using phpMyAdmin on your wp_categories table make your cat_name fields be:

    <!--CAO-->Maggie Cao
    <!--JAW-->Gil Jawitz

    The <!--CAO--> won't be displayed as it will be processed as a comment by the browser but the wp_list_cats will use the whole field to sort it.

    I know, ugly and kludgy ;)

  3. buskerdog
    Member
    Posted 7 years ago #

    Hmmm... that's interesting. But is there anyway to sort by name but display the description? Or is there a more verbose loop that can achieve a similar thing to wp_list_cats but allow for more customization?

  4. MichaelH
    Member
    Posted 7 years ago #

    Guess if you want ultimate flexibility start with a look at the list_cats() function in wp-includes/tempate-functions.php (starting at line 277).

    The problem with categories is the complexity of the parent idea. Also be mindful that version 2.1 (or whatever the next BIG release is numbered) changes the whole category process including combining link and post categories in the same table.

Topic Closed

This topic has been closed to new replies.

About this Topic