WAIT! DON'T MISS OUT OUR LAUNCH OFFER

You could save 50% and lock the price forever by switching to the Premium Annual plan. To proceed with the Pro Monthly plan, click on "Pay with Stripe" below.

Hidden
Freelancers, solopreneurs, small to medium-sized businesses that require a moderate amount of custom features.
Hidden
0,00 €

WAIT! DON'T MISS OUT OUR LAUNCH OFFER

You could save 50% and lock the price forever by switching to the Premium Annual plan. To proceed with the Pro Annual plan, click on "Pay with Stripe" below.

Hidden
Freelancers, solopreneurs, small to medium-sized businesses that require a moderate amount of custom features.
Hidden
0,00 €

50% OFF - LAUNCH OFFER

You're one of the first 200 customers and you get 50% off your annual subscription.

Oops! You need to be logged in to use this form.

50% OFF - LAUNCH OFFER

You could get 50% off your subscription by switching to the annual plan. To proceed with the monthly plan, click on "Pay with Stripe".

Hidden
Businesses and agencies that frequently update multiple WordPress sites and value collaboration.
Hidden
0,00 €

Add a code to automatically translate a specific text string in WordPress

Implementation guide

To implement the “Best Seller” badge for products in the “Featured” category, the following steps should be taken:
1. Ensure that a child theme is active on your WordPress website. If a child theme is not yet active, consider creating one to avoid losing your changes when the parent theme is updated.
2. Locate the functions.php file in your child theme’s directory. If it doesn’t exist, create it.
3. Copy the provided PHP snippet and paste it into the functions.php file of your child theme. This snippet uses WordPress and WooCommerce hooks to add a custom CSS class to the products that fall under the “Featured” category.
4. Copy the provided CSS snippet and add it to your child theme’s style.css file. This will style the badge to make it visible on the front end.
5. Save your changes and upload the modified files to your server if you’re editing them locally.
6. Make sure to test the changes in a testing environment before deploying them to your live website to ensure that they work correctly and do not interfere with your site’s existing functionality.

Code snippet

[code-php]
function wpdevai_translate_specific_string( $translated_text, $text, $domain ) {
    // Define your original and translated strings here
    $strings = array(
        'Original string 1' => 'Translated string 1',
        'Original string 2' => 'Translated string 2',
        // Add as many strings as needed
    );
    // Check if the current text domain matches your theme or plugin
    if ( 'your-text-domain' === $domain ) {
        if ( isset( $strings[ $text ] ) ) {
            $translated_text = $strings[ $text ];
        }
    }
    return $translated_text;
}
add_filter( 'gettext', 'wpdevai_translate_specific_string', 20, 3 );
[/code-php]
`); // Replace new shortcodes element.innerHTML = element.innerHTML.replace(codeCssRegex, (match, p1) => `
${p1}
`); element.innerHTML = element.innerHTML.replace(codeJsRegex, (match, p1) => `
${p1}
`); element.innerHTML = element.innerHTML.replace(codeHtmlRegex, (match, p1) => `
${p1}
`); }); } // Run the function replaceShortcodes();

by @Dot_COM