Support

Home Forums Event Espresso Premium Custom Template for Hiding Free Events

Custom Template for Hiding Free Events

Posted: April 29, 2016 at 3:06 pm


cvadev

April 29, 2016 at 3:06 pm

I’m having an issue with the single-espresso_events.php file.

I have copied the theme files from the Arabica directory and into my theme’s directory.
For some reason, after adding gibberish to the single-espresso_events.php file, I can’t get the gibberish to display. I then attempted changing the “Template Name” in the PHP comment within the single-espresso_events.php file and the new template name is correctly being updated within WordPress.

I thought I was modifying the wrong file, so as a test, I modified the single-espresso_events.php file within the EE plugin directory and I was able to render the gibberish!

So, it seems like the EE plugin’s theme is taking precedence somehow… but the template name correctly updates when I change it within my theme’s directory….

Essentially, all I’m trying to do is create a custom template that will hide the price of FREE tickets. I figured this would be a more elegant solution than directly finding the event-id, and all appropriate price selectors and setting their display properties to none.

Any ideas?


Josh

  • Support Staff

May 2, 2016 at 9:24 am

Hi there,

The more elegant selection is you use a filter and return an empty string when the price is zero, like in this example:

function espresso_convert_zero_to_nothing( $amount, $return_raw ) {
    // we don't want to mess with requests for unformated values because 
    // those may get used in calculations
    if ( ! $return_raw && ! is_admin() ) {
        $amount = $amount == 0 ? ' ' : $amount;
    }
    return $amount;
}
add_filter( 'FHEE__EEH_Template__format_currency__amount', 'espresso_convert_zero_to_nothing', 10, 2 );

You can add the above to a functions plugin or into your WordPress theme’s functions.php file.

If you find that you want to make other changes to the single event template where template modification is the way forward, you can follow this guide from the documentation to set up a custom template:

https://eventespresso.com/wiki/ee4-custom-post-types/#single_event_template


cvadev

May 4, 2016 at 3:18 pm

Thanks Josh. This does the job.
I tried searching for a list of hooks/filters on the site but couldn’t find anything.

Is this still the solution for finding a list of EE4 hooks/filters:
“In the meantime a search for do_action or apply_filter via your favourite IDE should bring up most of them.”

Reference: https://eventespresso.com/topic/developer-docs-with-action-and-filter-hooks/


Josh

  • Support Staff

May 4, 2016 at 4:51 pm

Hi,

It turns out there’s more specific information about EE4 hooks and filters in the developer documentation:

https://github.com/eventespresso/event-espresso-core/blob/master/docs/A–Best-Practices/ee-actions-and-filters.md

The support post ‘Custom Template for Hiding Free Events’ 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