Order by last name
-
Hello!
I am using the plugin on THIS page. I have used the guidance here to sort staff members by full name.
I need to order them by last name. For this, even though I am new to PHP, I have written the code below:
<?php
$name = “Firstname Middlename Lastname”;
$name_parts = explode(‘ ‘,$name);
$no_of_parts = sizeof($name_parts);
$last_name_index = $no_of_parts – 1;
$last_name = $name_parts[$last_name_index];
$first_names = chop($name,$last_name);
$reverse_name = $last_name . ‘ ‘ . $first_names;
?>It is made to move the last at the beginning of the full name, store the result in the $reverse_name, and then sort by $reverse_name. It does move the last at the beginning of the full name but I cant do this 2 things:
1) Use the value of the staff member post title as value for the $name variable;
2) Use $reverse_name for sorting.Can anyone help, please?
Thank you!
- The topic ‘Order by last name’ is closed to new replies.