Title: Using filter gettext
Last modified: August 22, 2016

---

# Using filter gettext

 *  [itzik lesher](https://wordpress.org/support/users/triplebit2/)
 * (@triplebit2)
 * [11 years, 8 months ago](https://wordpress.org/support/topic/using-filter-gettext/)
 * I’m not a programmer but I’d like to learn just one thing: to replace a certain
   text in a page with another one.
    I saw somewhere the following(please see below)
   code, which should do the job (which I suppose should be added to theme functions.
   php)and I’d like to add corresponding code in the right template file. My qustions:
   1. Suppose the orginal text is ‘text1’ and the replaced is ‘text2’, what is the
   syntax of the calling function in the template file? 2. Suppose the page(which
   its text I want to modify) uses index.php, which itself imports header.php. Can
   I put the calling function in header.php? Regards I. Lesher
 * _
    function my\_text\_strings( $translated\_text, $text, $domain ) { switch (
   $translated\_text ) { case ‘Related Products’ : $translated\_text = \_\_( ‘Check
   out these related products’, ‘woocommerce’ ); break; } return $translated\_text;}
   add\_filter( ‘gettext’, ‘my\_text\_strings’, 20, 3 );

The topic ‘Using filter gettext’ is closed to new replies.

 * 0 replies
 * 1 participant
 * Last reply from: [itzik lesher](https://wordpress.org/support/users/triplebit2/)
 * Last activity: [11 years, 8 months ago](https://wordpress.org/support/topic/using-filter-gettext/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
