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/