Posted: July 25, 2018 at 3:30 pm
Hello! I am attempting to make some pretty serious customizations to both the default events page as well as the events grid template plugin (seen here). Obviously I don’t want to touch the core stylesheets and template files, since they’ll be wiped whenever an upgrade comes along. All I’m trying to do is shuffle around and expand on the structure within my child theme, and in the case of the events page, output some custom field boxes on the sidebar. What would be the easiest and most brain-dead simple way to go about this? Hooks and filters? I have an elementary grasp on them, but anything to get me going in the right direction would be greatly appreciated. I just want my template modifications to be separated from the core files so they survive updates. Thank you very much! |
|
Hi Hilary, Welcome aboard! For the default event list page, you’ll follow these steps: Then, for the grid template plugin, you’ll follow these steps: Finally, if you have CSS customizations, those go in the style.css stylesheet of the child theme. If you’re having trouble overriding some default styles, you do well to use slightly more specific CSS selectors. This guide is not only fun, but very accurate: https://stuffandnonsense.co.uk/archives/css_specificity_wars.html (in most cases you will not need to go to0 far into the dark side) |
|
Josh, Thanks a lot, that worked perfectly. As far as editing core Event Espresso files goes, where would I find those? Specifically I’m looking to edit the structure of how individual event pages are laid out. I assume it’s as simple as what you had me do here (moving files to my children theme folder), but I’m not sure what the exact template file is called or where to find it. Thanks again~ |
|
It may not be as simple because the event page content is added via filter functions on the WordPress the_content filter hook. So it will depend on what you’re editing. So if you’re looking to edit the outer structure of the single event page, you’ll follow this: If you’re editing the structure of the individual parts of event content, the you can copy templates from the /public folder from within the plugin and put the copy into your child theme. For example to edit the section that has the venue information, you’ll copy over the content-espresso_events-venues.php template from the /public/Espresso_Arabica_2014 folder, then edit the copy in your child theme. |
|
Ah, yeah! I’m just trying to change the structure of the single event page. I understand the process enough after reading that link. Is Event Espresso completely contained to the plugins folder, or are there files elsewhere? I see a lot of the plugins / extensions in there, but not the core files themselves. For instance, where would I find single-espresso_events.php? |
|
All of Event Espresso’s core files are within its folder within /wp-content/plugins/. You will find a single-espresso_events.php template file in the public folder(within the theme folder there), but you shouldn’t use that file. Instead, you’ll need to base your single-espresso_events.php template off of your theme’s single.php template. WordPress just uses the single.php template file from your theme when it outputs an event page. If you want to add a single-espresso_events.php file to your theme, WordPress will use that file instead of single.php. This guide explains more: https://developer.wordpress.org/themes/basics/template-hierarchy/ |
|
OK great, that makes perfect sense. And similarly would the sidebar on a single events page be modified through sidebar.php? |
|
Possibly. If you have this code in your single events template:
Then yes, you could edit the sidebar.php template and your edits will affect the sidebar for the events page and every other page where the template calls get_sidebar(). Quite likely you want a specialized sidebar just for events, so what you could do is put this code in your single events template:
Then name your specialized sidebar template file Source: |
|
Josh, OK so, after going through the code and messing around with sidebar.php, I’m realizing that the info I want to shift into the sidebar is actually in single.php. So for instance if I wanted to move pricing details, calendar, any custom fields to the right of my event info . . . how would I go about doing that? I could very easily use my theme’s built-in scaleable columns, but how do I separate Event Espresso sidebar items from the rest of the content? Thanks! |
|
You could alter the markup within a variation of single.php, in this case single-espresso_events.php, then move the elements into a division that makes up a separate column. I mentioned earlier that you can copy templates from the /public folder from within the plugin and put the copy into your child theme. |
|
So I got into the EE plugins template folders and grab the info I need, then drop them in my new single-espresso_events.php with style tags around them? Or would it be simpler to, as you say, copy over those templates into my child theme and apply my new styles there . . . without combining the two files? |
|
You could do either. |
|
And, just to be clear, the templates added to the new single.php file would override the default plugin styles? |
|
No, the default plugin styles would still remain unless you’ve added additional styles that override the default plugin styles. |
|
Ahhh OK. I’ll target the plugin template styles in my child theme stylesheet to move them into a sidebar on the right. I imagine that’s the trick. |
|
The plugin template styles do not attempt to control the layout though, so that’s probably not necessary. If your theme already has markup & styles for a primary content area (or wider left column) and a secondary content area (for a sidebar to the right), you can add your markup to the template and the theme styles will take care of the rest. |
|
Hmm. I’m still having a few issues. Because EE’s info is just part of the WordPress loop, I can’t distinguish where it’s coming from among the many plugin folders I have. See here: This EE info just ends up displayed in the loop along with the rest of the content. I’m not exactly sure where to go to separate it. This is how many plugin folders I’m scanning through: Thanks for your help! |
|
Hi, The event info is not actually coming from any of those plugin folders. The information getting injected into the loop via the WordPress the_content filter. The template parts that get injected are all in the EE4 core plugin’s public folder. So the way forward for you will be to remove what’s injected into the content via the_content filter. So change this in your theme’s functions.php file:
to this:
Then, you can pull in the various template parts in your custom single-espresso_events.php template. A very simple example follows:
|
|
Yeah! That’s it. Thank you. Is there a list somewhere of all the EE template parts to call from? |
|
content-espresso_events-header.php |
|
The support post ‘Help with custom plugin templates / hooks / filters’ 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.