How to change the translation in WordPress without touching the translation file

In WordPress, the most common way to customize theme and plugin translations is to edit the translation files directly. However, this runs the risk of being overwritten during updates. Therefore, the use of gettext filters is recommended as a way to keep translations persistent.

An example is the following code

add_filter('gettext', 'change_admin_cpt_text_filter', 20, 3);

This filter can be used to dynamically change the translation text. Within the filter implementation, you can specify the string to be replaced and change it.

Using this method allows customized translations to be used persistently without losing translations during updates.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top