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

Image of Datadog

The Essential Toolkit for Front-end Developers

Take a user-centric approach to front-end monitoring that evolves alongside increasingly complex frameworks and single-page applications.

Get The Kit

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay