1

Yes, i've seen some answers on different questions but they didn't fit to my situation.

My theme has title tag enabled.

The title in the wp_get_document_title() function is different than the real title in my Search Page, which is "You Searched For %search% - %site_name%".

I need to translate the title, nothing more. I searched for You Searched in functions_php and every other .php file in woocommerce that has product or search related and couldn't find it.

I would appreciate any help. Thanks !

1
  • Many different plugins and themes can affect these in various ways. It may have nothing to do with WooCommerce - check any SEO plugins you have installed or deactivate all plugins, check the page title, activate one plugin at a time, check the title, to determine which (if any) plugin is setting it.
    – WebElaine
    Oct 24, 2017 at 19:26

2 Answers 2

0

In my case this problem was caused by Wordpress-Plugin Yoast Seo.

Take a look at your mySql-Database, Table wp_options and search for option_name = wpseo_titles

In the "option_value"-Field you can find the "You Searched for"-String and replace it by e.G. "Deine Suche nach"

0

Woocommerce and many themes provide filter hooks to modify various parts of the page, including the title tag.

You can create a custom function to modify the document title using the document_title_parts filter hook.

function custom_search_page_title($title_parts) {
    if (is_search()) {
        $title_parts['title'] = sprintf(__('You Searched For %s - %s', 'your-text-domain'), get_search_query(), get_bloginfo('name'));
    }
    return $title_parts;
}
add_filter('document_title_parts', 'custom_search_page_title');

Replace your-text-domain with the text domain of your theme or plugin.

To translate the title, you can use translation functions like __(), esc_html__(), or sprintf() if you need to insert dynamic content like the search query.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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