Change the Shop page title

You know that WooCommerce generates the Shop page automatically, you only need to select what page to use in the settings.
Also, it does not matter what title your page has, it will still use the title “Product – Your site name”.

How to change it?

Add this code at the end of the file functions.php in wp-content/themes/your-child-theme-name/:


/**
* Change the Shop archive page title.
* @param string $title
* @return string
*/
function wc_custom_shop_archive_title( $title ) {
if ( is_shop() && isset( $title['title'] ) ) {
$title['title'] = 'My Title';
}
return $title;
}
add_filter( 'document_title_parts', 'wc_custom_shop_archive_title' );

view raw

functions.php

hosted with ❤ by GitHub

This code will only work on the Shop page and won’t affect any other page in your website.


More Posts That You Might Like…


8 responses to “Change the Shop page title”

  1. […] can change the WooCommerce shop title with this tutorial from Nicola […]

    1. im new with code but where do you change the name , my shops default has Products and another line saying add new products here. thanks

      1. Hi Troy,
        You just need to change the name of the Shop page in Pages > All Pages. That one will be used.

  2. thanks. works like a charm. i edited it, so it return the actual page title of the shop page defined in wc:

    /**
     * Change the Shop archive page title.
     * @param  string $title
     * @return string
     */
    function wc_custom_shop_archive_title( $title ) {
        if ( is_shop() && isset( $title['title'] ) ) {
            $shop_page_id = wc_get_page_id( 'shop' );
            $title['title'] = get_the_title( $shop_page_id );
        }
    
        return $title;
    
    }
    add_filter( 'document_title_parts', 'wc_custom_shop_archive_title' );
    
  3. even a bit nicer:

    /**
     * Change the Shop archive page title.
     * @param  array $title
     * @return array
     */
    function wc_custom_shop_archive_title( $title ) {
        if ( is_shop() && isset( $title['title'] ) ) {
            $title['title'] = get_the_title( wc_get_page_id( 'shop' ) );
        }
    
        return $title;
    }
    add_filter( 'document_title_parts', 'wc_custom_shop_archive_title' );
    
    1. Hi there!
      Thanks for the tweak 🙂

  4. how to change woocommers button text add to cart to Shop now

Leave a Reply

Categories

Newsletter

Receive new articles from this blog directly in your inbox!

No spam guaranteed!

Blog at WordPress.com.

%d bloggers like this: