Posted: January 7, 2016 at 9:56 am
|
I’m using the People Add-on. |
Hi Susan, Is this within the admin or on the front end, if the front end within the event itself? If within the admin you can not currently order by Last name, only full name but clicking ‘Name’ – http://take.ms/Cw65D Types can also be order by clicking on name within that section – http://take.ms/fjd0O If within the front end you’ll likely need to create custom templates to alter the query but it depends on where you are looking at as to which template. |
|
|
Tony, Thanks for your reply. I need to order the people for the front end. I actually need to have 2 specific people (program directors) at the top of the list and the remaining people sorted alphabetically by last name. I use the WP Post Types Order plugin to “effortlessly” re-order posts using drag and drop. Ideally I would like to be able to do this with the People I add to the list in the People Add-on but it is not currently possible. Is this something you would consider adding to your plugin? Could you please suggest the easiest way I could achieve what I’m trying to do. I am technical/a developer but I don’t have experience with creating custom templates. If you could point me in the right direction it would be helpful. Thanks! |
Hi Janet, In the case of re-ordering the posts, you can use the WordPress plugin API’s posts_orderby filter. There is some basic info about how to use this filter in the codex: https://codex.wordpress.org/Plugin_API/Filter_Reference/posts_orderby In this case, the JOIN that’s involved gets the last name field from the database table where it’s stored. Which oddly enough is the attendee meta table, who knew!? Anyway, the readymade code in this snippet can be dropped into your theme’s functions.php file to get that part done: In the case of placing the program directors at the top of the list, that’s typically done in WordPress by running multiple loops. The first loop does the first list of the program directors, where the program directors could be in their own People category, then the second loop lists everyone else. There’s a really great example of how to set up multiple loops in the WordPress codex that you can follow: https://codex.wordpress.org/The_Loop#Multiple_Loops_in_Action |
|
|
Thanks so much for your help Josh. Your code to order by last name worked but in the end I’ve gone with this function to reverse the order so it shows people by id number ASC.
|
The support post ‘People Add-on – Order people or people-type list alphabetically by last name’ is closed to new replies.
Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.