Description
When you enter a price or a price range for an event and it is or starts with zero (0), then on the front-end it will show up as ‘Free’
If you would rather like to see the number zero instead of ‘Free’, there are two easy ways to do that.
Option 1: A snippet
Copy the below code into your (child) theme’s functions.php
file (or wherever you usually put custom code).
function tribe_tec_change_free_to_zero ( $translation, $text, $domain ) {
$custom_text = [ 'Free' => '0' ];
// If this text domain starts with "tribe-", "the-events-", or "event-" and we have replacement text
if( 0 === strpos($domain, 'the-events-calendar') && array_key_exists( $translation, $custom_text ) ) {
$translation = $custom_text[$translation];
}
return $translation;
}
add_filter( 'gettext', 'tribe_tec_change_free_to_zero', 20, 3 );
Option 2: The ‘Say What?’ plugin
The Say What? plugin actually does what the above snippet, but it gives you a nice user interface.
After installing and activating the plugin go to Tools → Text Changes and add a new entry like in this screenshot:
Click “Save” and you’re set.
Plugins
- The Events Calendar
Notes
- Originally written in May 2019
- Tested with The Events Calendar 4.9.2
- Author: András Guseo
- This is for The Events Calendar plugin. If you need a solution for RSVPs / tickets with Event Tickets or Event Tickets Plus, then this article might be helpful.