Categories :

How to Replace Text of the_content in WordPress

If you want to replace keywords and text in the_content? Add the following code to the functions.php file of your WordPress active theme OR in custom plugin.

function replace_text($text) {
    $text = str_replace('Have a coupon?', 'Haben Sie einen Gutschein?', $text);
    $text = str_replace('Apply Coupon', 'Gutschein anwenden', $text);
    $text = str_replace('Product', 'Produkt', $text);
    $text = str_replace('Price', 'Preis', $text);
    $text = str_replace('Coupon code', 'Gutschein Code', $text);
    $text = str_replace('Update Cart', 'Warenkorb aktualisieren', $text);
    $text = str_replace('Billing Details', 'Rechnungsdetails', $text);
    $text = str_replace('Additional Information', 'Zusätzliche Informationen', $text);
    $text = str_replace('Your order', 'Ihre Bestellung', $text);
    $text = str_replace('Shipping address', 'Lieferadresse', $text);
    return $text;
add_filter('the_content', 'replace_text',99);

Leave a Reply

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