Hello,
We apologize for the issue you are facing with setting up self-referencing canonical URLs for your WooCommerce category pagination pages. Unfortunately, the context provided does not contain specific instructions on how to set a self-referencing canonical URL for pagination in WooCommerce.
However, you can manually set canonical URLs for your product category pages by visiting the respective category page and using the Rank Math SEO Meta box. Here’s a general approach:
- Edit the Category Page: Go to the product category you want to edit in your WordPress dashboard.
- Rank Math SEO Meta Box: Scroll down to the Rank Math SEO Meta box.
- Advanced Tab: Navigate to the Advanced tab within the meta box.
- Canonical URL Field: Here, you can enter the desired canonical URL. For your case, you would enter
/categorie/shoes/?product-page=2
for the pagination page.
Make sure to update the category page after making these changes.
If you need further assistance or if this does not resolve your issue, please reply to this ticket, and a human agent from the Rank Math Support team will take over and provide more detailed help.
Thank you for raising this concern!
Hello,
Thank you for your query and we are so sorry about the trouble this must have caused.
Please try using the following filter code to forcibly set the canonical URLs of your paginated pages to self-referencing canonical:
add_filter( 'rank_math/frontend/canonical', function( $canonical ) {
if(is_product_category()){
$url = home_url($_SERVER['REQUEST_URI']);
if (strpos($url, '?product-page=') !== false) {
$canonical = 'https://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
}
}
return $canonical;
});
You may refer to this guide on how to add filters to your website: https://rankmath.com/kb/wordpress-hooks-actions-filters/
Hope that helps.
Thx it works like a charm !
Btw : maybe this could be an option in Rank Math because Google states in its documentation “Do not use the first page of a paginated sequence as the canonical page. Instead, assign each page its own canonical URL.”
Hello,
We are super happy that this resolved your issue. If you have any other questions in the future, know that we are here to help you.
If you don’t mind me asking, could you please leave us a review (if you haven’t already) on
https://wordpress.org/support/plugin/seo-by-rank-math/reviews/#new-post
about your overall experience with Rank Math? We appreciate your time and patience.
If you do have another question in the future, please feel free to create a new forum topic, and it will be our pleasure to assist you again.
Thank you.