WordPress.org

Ready to get started?Download WordPress

Forums

How to choose the first letter of the Last word when sorting alphabetically (4 posts)

  1. Joshuwar
    Member
    Posted 4 years ago #

    Hi...

    I'm using WordPress as a CMS for an agency website, where I'm using categories titled with people's names to collate seperate posts about them. So there might be a category called Bob Dylan, which pulls up news, works, and a biog from other categories.

    I'm using wp_list_cats to present a simple list of all these people. This orders the categories by name, alphabetically by default. That's fine, but I'd like to be able to sort by surname instead- ie. using 'Dylan' instead of 'Bob'.

    So I presume I'll need to use some kinda string manipulation to find the last seperate word in a category title, and use the first letter of that word to determine the alphabetical order, rather than the first letter of the entire string.

    Unfortunately I'm at a loss with where to start with scripting something like this, and I've not been able to find anything similar to guide me.

    Any nudges in the right direction would be extremely helpful...

  2. Joshuwar
    Member
    Posted 4 years ago #

    nobody got any thoughts on this?

  3. brduncan
    Member
    Posted 4 years ago #

    I could use this same thing. Anyone have thoughts?

  4. deadlycomputer
    Member
    Posted 4 years ago #

    simple php substring maniuplation
    php.net

Topic Closed

This topic has been closed to new replies.

About this Topic