wordpress query with lastname from title -


i have list hundreds of people , full name (first last) in title. there method query these posts in alphabetic order using last name (second word) title?

i found http://ms-studio.net/tutorials/sorting-titles-by-last-name-in-wordpress/ cant understand how work in wp query

    <?php     function posts_orderby_lastname ($orderby_statement) {         $orderby_statement = "right(post_title, locate(' ', reverse(post_title)) - 1) asc";         return $orderby_statement;     }             add_filter( 'posts_orderby' , 'posts_orderby_lastname' );      ?>      <?php $the_query = new wp_query( 'post_type=person&posts_per_page=100' );          while ( $the_query->have_posts() ) : $the_query->the_post(); ?>              <h4><?php the_title(); ?></h4>          <?php endwhile;          remove_filter( 'posts_orderby' , 'posts_orderby_lastname' );             wp_reset_query();      ?> 

this worked


Comments

Popular posts from this blog

javascript - oscilloscope of speaker input stops rendering after a few seconds -

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -