• 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!

    https://www.ads-software.com/plugins/simple-staff-list/

Viewing 1 replies (of 1 total)
  • B1gJ4k3

    (@b1gj4k3)

    Replace your user-view-show-staff-list.php file with the following:

    https://pastebin.com/8fn5P2tK

    and use the shortcode [simple-staff-list orderby=”lastname”]. It’s pieced together and pretty hacky, but it seems to work.

    You’ll obviously want to disable updates to the plugin if you change the core files.

Viewing 1 replies (of 1 total)
  • The topic ‘Order by last name’ is closed to new replies.