1

I have just over 8k products listed on my wordpress site using WooCommerce.

Some product links work fine, vast majority for some reason have an unwanted space and - though ( -) resulting in 404, when i edit the link to remove these 2 characters the link becomes functional again.

The link appears like this inside wordpress editor-

www.mydomain.com/product/ -randomproduct

On the frontend, the link appears as this:

Www.mydomain.com/product/%20randomproduct

I'm wondering if theres a way for me to bulk edit all the bad links to remove the 2 problem characters and fix my links.

Thanks for any help received.

1
  • Welcome to the portal Ali22 ! :)
    – jgangso
    Nov 19 '20 at 8:15
0

You can check how the site_url is stored in the wp_options table - make sure there is not a space after the url.

2
  • Thanks for the reply, i checked and theres no space after the url. I would say this doesnt effect all my products, just the vast majority. Hope i dont have to manually correct all the links
    – Ali22
    Nov 16 '20 at 22:17
  • You might try to add a filter to the url - developer.wordpress.org/reference/hooks/post_type_link - this will enable you to debug the string being used and to replace spaces with nothing - for exampling using str_replace
    – Q Studio
    Nov 17 '20 at 7:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.