Posted: January 22, 2015 at 1:17 pm
I am using EE4 4.4.6.p
I simply need to add the line of text “This is NY (U.S. Eastern) Time” right under the dates/times of an event, and right before the “content” (event description) of the post.
I realize I can simply add this line of text into the description as the very first line right before the actual event’s description every time I create a new event (which would “appear” to be right under the dates/times), but I am developing this website for a client and I already know they will simply not want to remember to add this line of text every single time they create a new event.
I already know how to create a copy of the single-espresso_events.php template and place it into my theme’s folder.
However it seems that in order to add this line of text I will need to somehow modify the function: espresso_get_template_part( ‘content’, ‘espresso_events’ ); in the core files.
Is there any way I can modify this function so that the line of text appears under the dates/times, and also is safe from being wiped out due to future updates of EE4?
Thank you so much!
Event Espresso 4 comes with a set of starter templates. You could copy those over to your theme folder, make some one line edits and then any additional edits would be preserved on a software update.
Please see this tutorial:
However, there is an easier method since you are wanting to add a short note near event description:
One example is for adding content before the event details area. Then next is for after the event details area.
You can then add the example to a site specific plugin or a child theme’s functions.php file.
Thanks, Lorenzo! Adding the function to add the message right before the event’s description worked perfectly.
This would be called a “hook”, right? If so, I’m still trying to get the hang of them.
Assuming what you describe above are in fact hooks to add a message/text/HTML before or after the event description, is there a “master list” somewhere of EE4 hooks that I can reference incase I need to add anything else to the single events page (aside from before or after the event description)?
A hook is basically a point in the application that allows you to ‘do something’ at that point.
There are 2 different types of hooks, Action hooks and Filter hooks.
Actions hooks are there to trigger some kind of action, usually a custom function that you hook onto that action call. These are usually used when you want to ‘add something’ into the application.
If you notice those two functions @lorenzo provided use add_action() to hook the custom function to that action, that’s because you are ‘adding’ that phrase.
The other is a filter hook, these are used to change something that’s already there. The original ‘value’ (which would be anything from a simple variable to an object) is passed to the filter, you change that all or part of that value and pass it back to be used. This can anything from some text to an object.
A lot of EE text phrases are passed through filters to allow you change them, although we recommend translating text using a plugin such as Loco Translate simply because it it easier to manage through the WP Admin (rather than constant adding to your custom function)
In terms of a master list for EE4, not currently.
Once EE4 is no longer in Beta we will likely create a detailed list of all of the hooks available, but currently we are constantly changing how EE4 works and also adding new hooks that allow easier customisations.
We are more than happy to point your in the right direction for any information you may need until then 🙂
Hello again, I wanted to share an additional resource that is now available for the templates for Event Espresso 4.
It explains how to the starter templates work with each other and you can view it here:
If you have any questions or something is confusing, then you can create a new support post here so we can help you:
The support post ‘Single Event Template Question – espresso_get_template_part’ 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.