Support » Plugins and Hacks » Hacks » Order WP_query by last word in title

Order WP_query by last word in title

  • Hi all,

    I’m developing a site with several custom post types and each of those with several custom taxonomies. One of the post types is people, and I would like to use the title to display the persons name. My issue is that I would like to be displaying alphabetically by the last word in the title rather then the first. I’ve searched the forums and web for anyone who has found a good solution for this and so far I’m not seeing much of use. Has anyone run into this and found a good workaround?

    Here’s what I’m starting with:

    <?php $my_query = new WP_Query('post_type=people&posts_per_page=-1&groups=directors&orderby=title&order=asc');
    while ($my_query->have_posts()) : $my_query->the_post(); ?>
    <img src="<?php echo get_post_meta($post->ID, 'board_member_photo', true); ?>" />
    <h2><?php the_title(); ?></h2>
    <p><?php echo get_post_meta($post->ID, 'company_title', true); ?></p>
    <?php the_content(__('Read more'));?>
    <?php endwhile; ?>
    <?php wp_reset_query(); ?>
  • The topic ‘Order WP_query by last word in title’ is closed to new replies.