Add .html extension to custom post type taxonomies

I’ve tested your first attempt with using a rewrite rule it works

add_action('init', 'add_html_ext_to_custom_post_type_taxonomies');
function add_html_ext_to_custom_post_type_taxonomies() {
    add_rewrite_rule('^product_cat/(.+)\.html', 'index.php?product_cat=$matches[1]', 'top');
}

but you have _ not – had you noticed this as you give your example as www.mydomain.com/product-category/product-category-name.html

If its not a mistake it might be you have another rule conflicting with it? and also have you flushed the rules? You could check using the Rewrite Rules Inspector plugin and also you can use it to flush the rules if you haven’t already done so.

Leave a Comment