Next/Previous Post Navigation in WordPress
Next/Previous Post Navigation in WordPress
July 16, 2024
CSS Responsive Table
CSS Responsive Table
July 18, 2024

July 17, 2024

WooCommerce Category Title with page number

If you have many products in a category and you display many products per page with pagination enabled then SEO experts suggest the page title to be unique and this snippet adds the page number to the title.

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

PHP

/* ---------------------------------------------------------- */
//         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;
}

See also

Leave a Reply

Your email address will not be published. Required fields are marked *

Level Up Your Coding Skills

Get the best CSS, HTML, and JS snippets delivered to your inbox monthly. 🚀
No spam—just coding gold! 💻✨"

We don’t spam! Read our privacy policy for more info.

cookie
This website uses cookies to improve your experience. By using this website you agree to our Data Protection Policy.
Read more