WordPress.org

Ready to get started?Download WordPress

Forums

Lastname, Firstname flip in display (3 posts)

  1. nearlythere
    Member
    Posted 9 years ago #

    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.

  2. Kafkaesqui

    Posted 9 years ago #

    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:

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

  3. nearlythere
    Member
    Posted 9 years ago #

    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.

    http://sligoarts.ie/list/artists-artforms/film-media/

    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.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.