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

Create and maintain end-to-end frontend tests

Learn best practices on creating frontend tests, testing on-premise apps, integrating tests into your CI/CD pipeline, and using Datadog’s testing tunnel.

Download The Guide

Top comments (0)

The best way to debug slow web pages cover image

The best way to debug slow web pages

Tools like Page Speed Insights and Google Lighthouse are great for providing advice for front end performance issues. But what these tools can’t do, is evaluate performance across your entire stack of distributed services and applications.

Watch video