Support

Home Forums Event Espresso Premium EE4 People addon – sort people alphabetically

EE4 People addon – sort people alphabetically

Posted: August 27, 2015 at 11:15 am

Viewing 5 reply threads


Ellen Kronen

August 27, 2015 at 11:15 am

I’m using the people addon which is great, but … is it possible to:

(1) sort people alphabetically
(2) exclude people from the full list if an event has expired.

Would also be great if you could show full entry on event page, and a longer excerpt on ‘all’ people page. If I could change the length of the excerpt that shows on the all people page, with a ‘read more’ link (like you would see on a blog post) that would probably do it (and save me having to duplicate content as an excerpt. Possible? or not?

See http://cp149.ezyreg.com/~nsns2799/site/people/ (note this is a development site so not really for public view, thanks).

Many thanks
Ellen


Dean

August 28, 2015 at 5:07 am

Hi Ellen,

1) Currently people can only be ordered by using the Order boxes in the event editor, add numbers in each box to define order (1 being at the top).

2) Can you clarify, do you mean exclude individuals or hide the full list?

Regarding the excerpts etc.

Would also be great if you could show full entry on event page

The single event pages use the “short biography” section in the Person editor. While deemed short, you can put a lot of text here.

However! If this is used, it is also used on the /people/ page without excerpt, so be aware of that.

and a longer excerpt on ‘all’ people page

Actually, the plugin shows the full description here, but it is theme dependant so your theme is likely over ruling and changing the length of what is shown. I would check your theme settings to see if there are any options regarding excerpt length.

However, you could use this function in a Site Specific Plugin (https://eventespresso.com/wiki/create-site-specific-plugin-wordpress-site/) to force the excerpt length:

  	function custom_excerpt_length( $length ) {
	    global $post;
	    if ($post->post_type == 'espresso_people') {
	    	return 20;
	    }
	    else {
	    	return 80;
	    }
	}
	add_filter( 'excerpt_length', 'custom_excerpt_length', 999 );

So 20 is for People, and 80 for everything else (characters, not words) so these are the values you would need to change.


Ellen Kronen

August 30, 2015 at 12:52 am

Thanks for this Dean.

I probably should’ve said I would like to be able to sort people alphabetically on the people archive page, ie http://cp149.ezyreg.com/~nsns2799/site/people/. Is that possible?

Also, I’d like to be able to add a title to the people page – it looks kind of bare without one!

Thanks for the function – I’ll add that in.

Regards
E


Dean

August 31, 2015 at 5:07 am

Hi,

Sort of:

function order_people_by_first_name_az( $query ) {

    if ( $query->is_post_type_archive( 'espresso_people' ) ){
		$query->set('orderby', 'title');
		$query->set('order', 'ASC');
    }
}
add_action( 'pre_get_posts', 'order_people_by_first_name_az', 1 );

Right now there is no post meta, so it’s impossible to hack the query and order by meta, which is why it’s ordering by first name.

We have a feature request ticket open asking for more options regarding this so I will add your plus 1 to it.

Regarding a title, the People “page” is in fact an archive page so it isn’t a page at all but dynamically generated by WordPress.

Most themes add some sort of title, usually Archive or PostType Archive, yours doesn’t.

I couldn’t find any filters/hooks to insert one though I may have overlooked it.


Ellen Kronen

August 31, 2015 at 2:24 pm

Thanks for that! Worked a treat.

Re the title, I’ve done a category.php page to get the title to show on other archive pages (eg http://cp149.ezyreg.com/~nsns2799/site/category/writers-on-writing-spotlight/) but not quite sure why it didn’t work on the people page. Amyway, alpha sorting of people by first name is progress! Looks way better.

Thank you,
E


Dean

September 1, 2015 at 5:40 am

Hi,

No problem!

It didn’t work most likely because People is not a taxonomy like Categories, but a custom post type, like Posts.

Viewing 5 reply threads

The support post ‘EE4 People addon – sort people alphabetically’ 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.

Event Espresso