Skip to content

Instantly share code, notes, and snippets.

@onemanparsons
Created November 4, 2020 10:37
Show Gist options
  • Save onemanparsons/2b8749fe28ef5a8bc72192aaa0792161 to your computer and use it in GitHub Desktop.
Save onemanparsons/2b8749fe28ef5a8bc72192aaa0792161 to your computer and use it in GitHub Desktop.
Use in child theme's functions.php. Useful to translate a handful of strings. For more extensive translations a plugin like Loco Translate comes in handy.
// Theme translations
function custom_text_translate($translated) {
switch ( $translated ) {
case 'The Shop' :
$translated = 'Donate';
break;
case 'Welcome to our online store. Take some time to browse through our items.' :
$translated = 'Welcome to our donations hub.';
break;
}
return $translated;
}
add_filter('gettext', 'custom_text_translate' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment