DEV Community

SnippFlow
SnippFlow

Posted 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: https://snippflow.com/snippet/woocommerce-category-title-with-page-number/
WooCommerce Snippets

Top comments (0)