Guest User

alphabetical authors

a guest
Feb 1st, 2019
197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.60 KB | None | 0 0
  1.                                 //resorting the "author" name, that is, the Author CPT Post title
  2.                                 $jjm_name = get_the_title( $p->ID ); // This also works if the "author" is a term.
  3.                                 if (substr_count($jjm_name, ';', 0, strlen($jjm_name)) == 1) { //is this a semicolon separated name?
  4.                                     // Generate output
  5.                                     $artist_name_parts = explode( ';', $jjm_name, 2);
  6.                                     $output = trim( $artist_name_parts[1] ) . ' ' . trim( $artist_name_parts[0] );
  7.                                     echo $output;
  8.                                 } else { //if no semicolon, just output the term name as-is
  9.                                     echo get_the_title( $p->ID );
  10.                                 }
Add Comment
Please, Sign In to add comment