0

I want to replace ORDER word with something like Entry Form everywhere in the wordpress website. I am trying following method to replace Order word.

add_filter('gettext', 'translate_reply');
add_filter('ngettext', 'translate_reply');

function translate_reply($translated) {
$translated = str_ireplace('Order' , 'something' , $translated);
return $translated;

But when i apply this method some some sotecode stop working like order_id/ order_date etc.

Any other idea how can i replace ORDER word without any extra effect.

3
  • Can you please explain more what you like to do? It is not very clear. Thanks.
    – Greeso
    Aug 4, 2017 at 2:00
  • I have a customer who have sports club and he want to receave all the payments from the website. But whenever someone submit the entry form so website always shown YOUR ORDER HAS BEEN PLACED/ ORDER ID/ ORDER DETAILS etc he requested me to change the ORDER word with ENTRY FORM. Aug 4, 2017 at 2:07
  • Here's a proposition: Install locotranslate, filter the strings with the word Order and translate them instead of "cleverly" doing it with the gettext filter. Aug 4, 2017 at 3:23

2 Answers 2

0

It is still not very clear to me. But as far as I understand, this might help: https://codex.wordpress.org/Plugin_API/Filter_Reference/the_content

Basically this is a filter that you can use to filter your content before it is displayed on screen. So, your content filter function can then do test if the order is a standalone word or not, and if it is, then replace it. I hope this help.

0

You could just write the full exact string then replace the 'order'. That way it won't change anything else like 'order id'.

function hpm_replace_text($translated_text) {
    switch ($translated_text) {

        case 'The order has failed' : // write the original string here
            $translated_text = 'The entry form has failed'; // make a change to it
            break;

        case 'The 2nd order has failed' : // write the original string here
            $translated_text = 'The 2nd entry form has failed'; // make a change to it
            break;

         //etc
    }

    return $translated_text;
}
add_filter('gettext', 'hpm_replace_text');

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.