1

I am using woo-commerce

I have bellow code to remove the post type "product" slug from url and it works fine.

Product url = http://example.com/product/product-name/ to

Product url = http://example.com/product-name/

function df_custom_post_type_link( $post_link, $id = 0 ) {  
$post = get_post($id);  
if ( is_wp_error($post) || 'product' != $post->post_type || empty($post->post_name) )  
        return $post_link;  
    return home_url(user_trailingslashit( "$post->post_name" ));  
}
add_filter( 'post_type_link', 'df_custom_post_type_link' , 10, 2 );

function df_custom_rewrite_rule() {
    add_rewrite_rule('(.*?)$', 'index.php?product=$matches[1]', 'top');
}
add_action('init', 'df_custom_rewrite_rule');

Now How to remove taxonomy-base from url

Example:

Product category url = http://example.com/product-category/product-category-name/ to Product category url = http://example.com/product-category-name/

1 Answers1

0

This is an very old question actually.. And your question is simple to be answered: WooCommerce itself says that this isn't possible. Quote: "Unfortunately this is not possible due to the way WordPress resolves its URLs."

But I did some research and there are possibilities to fix this with plugins, or maybe you are very handy with coding it yourself. These plugins are designed to remove the custom taxonomy and the posttype from the WC urls. I don't know if im allowed to share the link with you, but this is your answer for sure. Oh, and its a payed plugin... Forgot to mention. http://www.perfectseourl.com

  • 1
    Sure - you can share a link, as a reference. A good answer would include an example, though, not just a recommendation. – Mogsdad Dec 08 '15 at 16:54
  • What kind of example should I give? I checked the official documentation from WooCommerce as well, so there is not much to share I guess :) – Stucmeister Dec 09 '15 at 17:27