I use the events Calendar Plugin and I want to change some words

The “Now onwards” string is translated with _x() which is different than __() because it allows context to be added to the string being translated.

Because there is context, you need to use gettext_with_context instead of gettext. Here’s a simple example based on the one in the WP.org Code Reference:

function example_gettext_with_context( $translated, $text ) {
        if ( 'Now' == $text ) {
              $translated = 'Today';
         }

   return $translated;
}
add_filter( 'gettext_with_context', 'example_gettext_with_context', 10, 2 );

You can find the relavent code in the Events Calendar plugin here and here

The Events Calendar website also has some detailed examples.

Leave a Comment