DEV Community

SnippFlow
SnippFlow

Posted on • Edited on

WooCommerce Category Title with page number

If you have more products in a given category and you display several products on a page with pagination enabled then SEO specialists recommend the page title to be unique, and this snippet add the page number to the title.

Category Title page 1
Category Title page 2
Category Title page 3
…

`/* ------------------------------------------- */
//   Snippflow Category Title with page number  //
/* -------------------------------------------- */

add_filter( 'woocommerce_page_title', 'custom_woocommerce_page_title' );
function custom_woocommerce_page_title( $page_title ) {
  if ( function_exists( 'is_product_category' ) && is_product_category() && is_paged() ) {
    $current_page = get_query_var( 'paged' );
        $page_title .= ' page '. $current_page;
  }
  return $page_title;
}`
Enter fullscreen mode Exit fullscreen mode

Full article: WooCommerce Category Title with page number
WooCommerce Snippets

Top comments (1)

Collapse
 
scott_morrison_39a1124d85 profile image
Knowband

Useful little SEO improvement for WooCommerce stores with paginated category pages. Adding the page number to category titles helps create unique titles for search engines and avoids duplicate title issues. Simple, lightweight, and very easy to implement.