Support » Plugin: WooCommerce » How to change shop title in page head?

  • When I change the title of my WC shop page, this is nicely reflected on the page. But, the title of the page in the page header (that is, in the <head> section of the HTML) does not change and remains as “Products”.

    When I use a filter to change the shop title, the title of the page in the body of the page changes, but not the title of the page in the <head> section.

    How to change the title of the shop in the <head> section of a WC shop?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Support Jesse Pearson (a11n)

    (@jessepearson)

    Automattic Happiness Engineer

    @mastababa The title in the <head> section is output via wp_head(), which uses wp_get_document_title() to get the actual title there. There is a filter that can be used to modify the title: pre_get_document_title. This would take a little bit of code to get it to only change for that page, though.

    You could use something like Yoast to rewrite your titles, which may be easier and more efficient.

    Due to the age of this thread I am setting it to resolved. If you still need further assistance you can change the status to not resolved.

    Thread Starter Babak Fakhamzadeh

    (@mastababa)

    That indeed worked. This is what I did:

    add_filter('pre_get_document_title', 'change_shop_title');
    function change_shop_title($title) {
    	if (is_shop()) {
    		return __("My new title", "mytranslationstring")." - ".get_bloginfo("name");
    	}
    
         return $title;
    }
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How to change shop title in page head?’ is closed to new replies.