Wrong Prev/Next-Links on search pages
-
Hello,
I recognized, that the rel=”prev” and rel=”next” links (and even the canonical link at property=”og:url”) in the head of search pages are showing wrong URLs – as pretty links, that we don’t use for search results.
Tested on a local test installation with:
- WordPress 5.1 DE
- WooCommerce 3.5.6 (with demo products and one duplicated product to get a second search results page)
- WooCommerce Blocks 1.4.0
- Yoast SEO 9.7
- Theme: Storefront 2.4.3
The problems:
1.) E.g. as next link for
https://mydomain.com/page/2/?s=test&post_type=product
it is showing
https://mydomain.com/search/test/page/2/
.The links are working, but are only showing the normal WordPress search results, and not the WooCommerce product results (please note the “&post_type=product” in the correct link, that is missing in the pretty link).
2.) When linking to a certain category, the pretty link is also “forgetting” the category info, e.g. as next link for
https://mydomain.com/shop/category-title/page/2/?s=test&post_type=product
it is still only showing
https://mydomain.com/search/test/page/2/
.3.) And a third problem, that results from the missing “&post_type=product” in the pretty link:
Because of different settings, how many search results are shown on WordPress and on WooCommerce-only search results, the “next”-link can link to a 404 error page, e.g.:- 13 search results
- 2 search pages for WooCommerce search, when 12 results on every page
- 1 search page forWordPress search, when 18 results on every page
Therefore, when the “next”-link in the source code of the WooCommerce result page links to “https://mydomain.com/search/test/page/2/”, this links to a 404 error page.
- The topic ‘Wrong Prev/Next-Links on search pages’ is closed to new replies.