Posted: September 24, 2018 at 9:37 am
|
I am customizing upcoming events widget to display venue information. Tried to follow https://eventespresso.com/topic/display-event-venue-details-as-a-sidebar/ But doesn’t work. Could you please help me? |
One issue with the code is the second parameter in each of those 3 template tags, is for controlling how the venue information is output (in other words, check the source in public/template_tags.php if you’re not sure what you’re setting “true” for) In this case, you’re setting those to TRUE and setting a variable. TRUE means you want to echo, so you’ll either set those to false, then echo out the variables later. Or just remove the variable assignments e.g.
|
|
|
September 24, 2018 at 12:22 pm I correct the mistakes, however, still cannot get the venue id by using espresso_venue_id( $event->ID() ). The $event->ID() did have the right id of the event. However from the event to the venue, it just get an id of 0. |
September 24, 2018 at 12:33 pm I can’t tell from what you’ve posted if you even have access to the $event object at that point. Maybe you can post a gist or a pastebin that includes the full code in context. |
|
|
Thank you Josh, From line 498 to 516, I can echo the event id, however it doesn’t give me the venue id. |
The reason being is you’ve made the ID into a string:
The correct data type there for the ID parameter is an integer. In other words, you need to remove the double quotes there. Also, please note the $id variable is already set on line 430, |
|
|
Josh, even the double quotes are removed, the error is still there. |
|
when I look into the codes, espresso_venue_id() using get_venue($eventid), however, the actual get_venue function require venue id. |
September 25, 2018 at 10:24 am
You could just pull the venue object directly yourself if you know the ID:
Or you can pull the venue directly from the event object if you have one (you do):
If |
|
September 25, 2018 at 10:32 am It actually depends on the context of the post type the code is running from. Instead of using the code from the other forum post, which was likely intended to be used on an event post type, what you could do is get the venue ID from the event object itself. e.g.
|
|
The support post ‘How to get venue information in upcoming events widget’ 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.