Support

Home Forums Event Espresso Premium Custom Order of events on archive

Custom Order of events on archive

Posted: October 29, 2014 at 4:19 am

Viewing 8 reply threads


Kyle Nel

October 29, 2014 at 4:19 am

Hi Folks, running the latest version of EE 4.4.3.p on WordPress 4.0.

I would like to provide the option to manually sort the events on the event archive for a site.

Have you got a recommended suggestion for doing this?
Thank you.


Lorenzo Orlando Caum

  • Support Staff

October 29, 2014 at 1:01 pm

Hi Kyle,

The closest option to this would be to cluster events within a category. Then several of these category shortcodes could be added to a WordPress page:

[ESPRESSO_EVENTS category_slug=”featured-events-1″]
[ESPRESSO_EVENTS category_slug=”featured-events-2″]
[ESPRESSO_EVENTS category_slug=”featured-events-3″]


Lorenzo


Kyle Nel

October 30, 2014 at 3:33 am

Hi Lorenzo, thanks for the response.

The problem I have with the shortcodes (and the main reason I am sticking with archives for the site) is that I can’t see how to modify the design and layout of the events in a shortcode.

I have modified the archive to display each event within an accordian, I wouldn’t know how to make a shortcode do this. Any suggestions?

Thank you.


Dean

October 30, 2014 at 5:56 am

You could create a custom query instead and add it to a page template – here’s an example query https://gist.github.com/joshfeck/e3c9540cd4ccc734e755


Kyle Nel

November 12, 2014 at 3:29 am

Hi Dean, thank you very much for your previous advice and I have done exactly what you said. I used that custom query to generate the list of events on my event archive. It works a treat…until I try to introduce a meta_key and try to sort by that. It simply displays this as normal. Here is my slightly modified query:

$atts = array(
‘title’ => NULL,
‘limit’ => 100,
‘css_class’ => NULL,
‘show_expired’ => TRUE,
‘month’ => NULL,
‘category_slug’ => $currentCategory,
‘meta_key’ => ‘order’,
‘order_by’ => ‘meta_value_num’,
‘sort’ => ‘ASC’
);

global $wp_query;
$wp_query = new EE_Event_List_Query( $atts );

if (have_posts()) : while (have_posts()) : the_post();

Is there something wrong with using meta values for sorting in this way?

Cheers folks


Seth Shoultes

  • Support Staff

November 12, 2014 at 1:17 pm

Hello Kyle,

I’m not sure ‘meta_value_num’ is available in this query.


Josh

  • Support Staff

November 12, 2014 at 1:56 pm

Hi there,

Yeah, the the meta value gets filtered out. You can use the post_orderby filter instead. Here’s a good answer from stackexchange that may help:

http://wordpress.stackexchange.com/a/15629


Kyle Nel

November 13, 2014 at 4:31 am

Thank you Josh. I got that working mostly. I am still working out how to make that work with a numerical field – the example works with meta_value which sorts alphabetically and replacing meta_value_num in this code doesn’t seem to work.

Unfortunately this leads to values of 1, 11, 111 appearing before 2 and 22 etc. I got around this by starting the numbering at 10 or 100.

Just thought that information might be useful to other members if they come across this same situation.


Josh

  • Support Staff

November 13, 2014 at 1:01 pm

Hi Kyle,

Here’s another related Stackexchange thread that may help.

http://wordpress.stackexchange.com/questions/13129/wordpress-orderby-numeric-value-not-working

Viewing 8 reply threads

The support post ‘Custom Order of events on archive’ 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