Posted: October 31, 2017 at 7:52 am
|
Hi, I’m trying to display the next 4 upcoming events on our homepage using Essential Grid, but the only way to get it to work successfully is with this parameter which calls them out individually: The problem here is we need to update it manually. Ideally I want to add these parameters and it seems it should work, however it doesn’t and seemingly pulls random events orderby=Datetime.DTT_EVT_start&order=asc I’ve been running the below code to try and find the proper parameter calls and when you look at the results it seems to be working, but the next 4 upcoming events are not being displayed. Any thoughts on how to accomplish this? in child theme’s function.php:
|
Hi there, Essential grid will just be using WP_Query, which won’t know what ‘Datetime.DTT_EVT_start’ is. Can you send me a copy of the plugin so I can take a look? If so you’ll need to host the zip file somewhere (Dropbox for example) and post a link we can use to download it. |
|
|
Thanks Tony. I will let you know when I get it on a drive for you. |
|
Tony, I can’t upload the file from work due to restrictions, but this is the website for the app: https://essential.themepunch.com/. i’ll try to get the app up there this evening. |
|
I’ve played a little more and got the following to function, however the start dates are still not showing. This is based on another topic that says it works using start_date: You can see the below in action at https://www.designandmine.com/ The echo text is right above the pictures in Upcoming Events and can be highlighted as they are purposefully hard to see.
|
|
Tony, Here is the link to the app for you to install: |
There’s a lot wrong with the code your using above.
One problem your going to run into with this testing is that you are using the built in EE functions to query the events, the EE functions take car of all of the joins within the query for you, so the query_args you pass to those functions will not work with a pure wp_query call (which Essential grid uses). SO even if you pull the correct events with your query, and then pass the same args to essential grids query, it wouldn’t work. For that query to work you’ll need to add the joins that EE does for you and then set the orderby (and I’d advise adding a group by post.ID) take a look here: https://gist.github.com/Pebblo/46702059755a1ba5b30d2b447e6c413e |
|
|
Thanks Tony. As you can see, i’ve pieced this together from many different sources, with this one being the initial source https://eventespresso.com/topic/using-ee_event_list_query-to-sort-events-by-start-date-instead-of-post-date/ I’ll take a look at the gist you mentioned and work from there. But honestly, i’m not sure why I need to do any custom code at all as i’m just trying to display the next 4 upcoming events in a essential grid. If there’s a better grid tool that can be used to work with event espresso, please let me know 🙂 Thanks again for the help. |
Yeah, I can see you’ve pieced it together, but it won’t work with how you have it now. With WP_DEBUG enabled you’ll get all kinds of notices of undefined variables.
There’s only so much we can do to integrate with various different plugins, but as long as the query is filtered its usually possible to get the details needed (as it is with the above). Adding the above snippet I provided should just work how you expecting without any other custom code.
EE has its own grid tool – https://eventespresso.com/product/eea-events-grid-view-template/ It doesn’t have all of the features essential grid does, so I can’t say its better, but it does pull the EE events without custom code 😉 |
|
|
The link you sent is working much better and I can see how the EE works with WP now It’s still not 100% as it is skipping some events. I think it’s related to the group by post id since the events aren’t always entered in perfect date order. So you can have a higher post number that takes place before the post right before it. But the code you referred me to was a great help! I’ll also look into the EE grid tool as well.
Completely understood. We didn’t initially create the site, but were made to believe that Ess Grid and EE were chosen since they already were integrated 🙂 Not a knock on EE, just what we had been led to believe. Thanks again for the help! |
|
FYI, it was not related to the post id. some of the events entered didn’t have the proper category assigned and were excluded from the query. So the code is working completely as expected! Putting the link here for future developers, but same as what you posted earlier. Thanks Tony! |
Great, I’m glad it’s working. Just to give some info of the group by post.id, when a single event has multiple datetimes within it the query will pull multiple of the same post because the dateime event ids match the post id. As they are all the same event the group by just makes sure one post is pulled. |
|
The support post ‘Using DTT_EVT_start as orderby parameter for Essential Grid’ 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.