Support

Home Forums Event Espresso Premium Upcoming Events for a Venue on the Venue Details Page

Upcoming Events for a Venue on the Venue Details Page

Posted: February 20, 2019 at 9:55 am

Viewing 12 reply threads


mcotten

February 20, 2019 at 9:55 am

Hello Folks,

I’m trying to add the code snippet for “Print a list of upcoming events for a venue on the venue details page” on this page: https://eventespresso.com/wiki/useful-php-code-snippets/#venue-event-list.

However, I see several venue template files so I’m not sure which one I’m suppose to be adding it to, where it should go or if I’m suppose to copy that code into the file in its entirety. I don’t have a lot of experience with PHP. I would much rather be working with shortcodes but Event Espresso 4 has none for venues. Hopefully. that will change soon.

I would like the upcoming event list to appear after the venue description, before the location info. Also, I’m using the latest version of the Avada theme and have a child theme setup.

Any help would be much appreciated. Thank you.


Josh

  • Support Staff

February 20, 2019 at 10:28 am

Hi,

You’ll actually put the code into its own plugin. Here’s a guide that shows how to put together a single-purpose plugin:

https://eventespresso.com/wiki/create-site-specific-plugin-wordpress-site/


mcotten

February 20, 2019 at 12:58 pm

Thanks for the quick reply. Actually, I was able to add it to my child theme functions.php and the list displays close enough to where I wanted it after updating it to display “before the content”.

I wasted hours on this last night because the instructions were misleading. (And I’m a newb when it comes to PHP.)

I chose Event Espresso for this project because it supported single event pages with multiple dates/times and venue page support. I know I’m spoiled with Avada but I’d like to see more options in the plugin UI or more shortcode options in the future.

Thanks again.


Josh

  • Support Staff

February 20, 2019 at 1:02 pm

Hi,

I’m curious to know what part of the instructions you think were misleading?


mcotten

February 20, 2019 at 1:19 pm

This part specifically “add the above to an action found in the venue template”. Plus the page is so long that only at the top does it mention “The Solution: Create your Site Specific Plugin”.

As a WordPress user, I know the fewer the plugins the better, so why would I need to create a custom plugin when I could have just added this to my child theme?


Josh

  • Support Staff

February 20, 2019 at 1:53 pm

What that code comment is trying to communicate that you can use other hooks found in the venue template. So for example instead of adding to the
AHEE__content_espresso_venues_details_template__after_the_content
action, you could instead add to:
AHEE__content_espresso_venues_details_template__before_the_content

I know the fewer the plugins the better

That’s not necessarily true that having one less plugin is better. There are good reasons to use a plugin instead of a functions.php file. Here’s an article that explains a bit more about that:
http://ottopress.com/2011/creating-a-site-specific-snippets-plugin/

why would I need to create a custom plugin when I could have just added this to my child theme?

You don’t need to, but it’s recommended. A child theme’s functions.php is OK, but we still recommend the plugin as a better way to keep your site’s custom code organized, neat, and tidy.


mcotten

February 20, 2019 at 3:42 pm

Yes, I realized how I misinterpreted the instructions now, but my preference would be to use the child theme. The beauty of WordPress is you can do things in more than one way.

As a designer, I often see developers determine a certain way is best but then don’t realize that the added complexity makes it much more difficult for the end user.

In this case, all I wanted to accomplish was to display upcoming events on the venue page. This is something that should be built into the UI or available via a shortcode. To have to copy a snippet and create a custom plugin for such a basic feature seems sort of ridiculous from my point of view.

I have clients that have depended on plugins that suddenly become unsupported so even end users know to limit the need to rely on plugins, even though that would not be the case with a site specific plugin.

So I’m not trying to be overly critical but perhaps the devs at Event Espresso are relying too much on the ability to create site specific plugins when they should be adding additional UI elements or shortcodes. That would make the product easier to use for designers like myself and is probably why themes like Avada are so popular.

This is just my opinion of course but hopefully it’s useful feedback for the Event Espresso team to take into account. A product that supports more features without customization will make it more accessible, more popular and lead to more sales.

It was really difficult to find an event manager that did not rely on recurring events, when it makes more sense to have a single page that can list multiple dates and times and still support some type of calendar display. Obviously, you guys figured that out with EE3 vs. EE4.

Regardless, I’m thankful that Event Espresso has a responsive support forum so I’ll post here whenever I find myself not being able to figure something out on my own again. Thanks again for the assistance.


Josh

  • Support Staff

February 20, 2019 at 4:07 pm

Thanks for your feedback.

To your credit, you were able to get the list to display “close enough to where I wanted it after updating it to display “before the content””.

Had that been a shortcode you would need to add that shortcode to every venue page, which would make for a repetitive task.

If it were an option to turn/on/off the display of events on venue pages it wouldn’t necessarily show the events where you wanted.

In other words, using a snippet can be a very powerful, useful tool because it allows you, the designer, to control the display of the list of events beyond what options and shortcodes can offer, right down to tweaking the html. And you make a change one time to affect all venues.

A thought I can share is the Event Espresso team actually tries to avoid adding options for every potential item that could be added, moved, or removed. If the reliance was on options pages, the number of options on each page would reach untenable proportions, even if the options were limited only to items & elements considered as basic features. This is in agreement with WordPress core’s philosophy outlined here:

https://wordpress.org/about/philosophy/


mcotten

February 20, 2019 at 4:48 pm

Thank you for providing further explanation. I do prefer design control using CSS but obviously that has it’s limitations. Using WordPress, I’ve mostly avoided template changes since they are constantly overwritten by updates and the only way to avoid that is utilizing a child theme. One of the reasons I’ve had to rely on Avada and don’t have any experience with site specific plugins.

WordPress core philosophy is obviously what has lead to it being so popular but could also be considered a weakness since it lacks core features and is reliant on plugins for so much of its functionality as a CMS. UI’s are improving for both being powerful and easy to use. Avada seems to be able to do well with balancing control and usability but even it has a learning curve for a website owner that only needs to make occasional updates.

I look forward to further exploring Event Espresso’s capabilities.


mcotten

February 28, 2019 at 8:30 pm

What conditional can I use before the code snippet that would prevent it from displaying if the venue has no events? A venue with no events still displays “Upcoming events at this venue”.


Tony

  • Support Staff

March 1, 2019 at 2:36 am

Around THIS LINE.

You can add:

if( empty( $venues ) ) {
    return;
}

So if there’s no venues returned it returns from the function.


mcotten

March 1, 2019 at 8:23 am

Thank you! Actually, since it’s a venue searching for events it needs to be.

if( empty( $events ) ) {
     return;
}

Your help is much appreciated. I’m patting myself on the back now.


Tony

  • Support Staff

March 1, 2019 at 8:42 am

Yeah that’s correct, my apologies I must have had venues on the brain when writing.

Viewing 12 reply threads

The support post ‘Upcoming Events for a Venue on the Venue Details Page’ 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