Knowledge Base

Quick Translate or Replace Single Words

The method described below uses our HelpGuru theme as an example, but will work for text in any theme or plugin

If you’re using a theme like HelpGuru, you may wish to change a single word or phrase to something else. We can do this with the in In this example we will be changing Knowledge Base to Help. Here is a screenshot of before

helpguru-knowledge-base-text-before

and after

helpguru-knowledge-base-text-after

It is recommended you perform this function in a child theme, doing so will ensure that your change is not affected by any theme updates.

 

Upload the helpguru-childtheme.zip that was included in the theme download package. This can be done from Appearance > Themes > Add New > Upload and upload and activate the HelpGuru child theme.

With the theme active, edit the themes functions.php file, this can be done from Appearance > Editor. And Selecting the functions.php file.

Add the following code:

add_filter('gettext', 'translate_text'); 
add_filter('ngettext', 'translate_text');
function translate_text($translated) { 
  $translated = str_ireplace('Knowledge Base', 'Help', $translated); 
  return $translated; 
}

helpguru-theme-translation

 

Was this article helpful?

Related Articles