Support » Plugins » Lastname, Firstname flip in display

  • I fantaasize about being able to order a list of posts according to the ‘last’ word…

    That is, I want the page to display:

    Firstname Lastname

    but be ordered according to the Lastname (or last word)

    I can’t think of any tricks for this completely wacky idea.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Does “Firstname Lastname” represent the post title for this list of posts? And if it does, are you already ordering posts by title? I’ll have to assume so, as you provide no other information needed to devise a not so completely wacky solution for this… First, enter your posts’ titles as:

    Lastname Firstname

    This way you store the information befitting the order you want to display it in (i.e. alphabetically) without the need for serious retooling in the background later on. Then in your template replace the_title() template tag with this bit of PHP:

    $title = preg_split('/ /', $post->post_title);
    echo $title[1] . ' ' . $title[0];

    i didn’t think it could be that easy. thanks very very much, Kafkaesqui. i’m a php newbie.

    sorry if i was vague! i always try not to be.

    yes i am talking about post titles. and only in specific categories, and some of the names will be three words (or more) and some single.

    at the moment– and this is horrible– i order them *gulp* by date in order to get them to display on the page correctly. i had them order by firstname but that was not working too well.

    i’ve obviously not thought this through very well, as i realized there are organisation names mixed in with individual’s names.

    hm… maybe i could use a custom field to mark some as organisations before reworking the title! i’ll give it a try.

    thank you thank you.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Lastname, Firstname flip in display’ is closed to new replies.