0

I'm recently added this code to my Wordpress website to add .html for my product category. It worked okay with the category (http://mywebsite.com/parent-category/product-category.html) but when I clicked the pagination, the link turned into (http://mywebsite.com/parent-category/product-category.html/page/2)

This is a code that i added to function.php on my site

function wpse_178112_category_permastruct_html( $taxonomy, $object_type, $args ) {
if ( $taxonomy === 'product_cat' )
    add_permastruct( $taxonomy, "{$args['rewrite']['slug']}/%$taxonomy%.html", $args['rewrite'] );
}

add_action( 'registered_taxonomy', 'wpse_178112_category_permastruct_html', 10, 3 );

Please help, I'm just a Wordpress newbie 😔.

Thank you!!!!!!!!!!

5
  • 3
    Why are you adding .html to your URLs? Please update your question to provide some context as to the problem this solves, it may be that add_permastruct is not what you need but it's difficult to tell with what you have ( it may also be that adding .html to your URLs is unnecessary or even harmful )
    – Tom J Nowell
    Commented Dec 15, 2017 at 14:07
  • Thank for your response, I've read about the SEO Friendly URL, and they said that the link with .html extension would be more friendly with SEO system. I'm new to Wordpress, so could you please explain for me a bit about it?. I'll appriciate that, thank you!. Commented Dec 15, 2017 at 14:54
  • 2
    @bonjourimcam That’s just not true. Think about it. WordPress runs millions of sites and the vast vast majority aren’t doing this but don’t have SEO problems. And major SEO plugins don’t even bother with this feature. Content and links are exponentially more important. Commented Dec 15, 2017 at 15:19
  • @bonjourimcam it's a common myth, nothing more. By changing your URLs you'll actually incur a hit.
    – Tom J Nowell
    Commented Dec 15, 2017 at 15:21
  • Thank guys, but, is there any other way to solve this problem without removing the .html extension on my url?. I'd like to keep the .html extension in my link, any suggestions, guys? Commented Dec 15, 2017 at 15:36

1 Answer 1

0

Adding .html won't do anything for SEO's sake - in fact, it will more likely cause problems than anything else. WordPress (and therefore WooCommerce) don't use HTML files to display - it's PHP files, which is why if you go to a page like the login, by default it's something like example.com/wp-login.php. Out of the hundreds or thousands of WordPress sites I've worked with in my time working for WooCommerce, none of them needed to add .html to a page for any reason, so I would highly suggest against it.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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