Hi play33.
Removing /product/ from the URLs is not advisable due to the way WordPress resolves its URLs. That can lead to a number of problems with performance and duplicate URLs.
More info here: Removing /product/ from the URLs
–
As an alternative you can add the brand to the products urls without removing the base. The code below does the trick:
add_filter( 'woocommerce_register_post_type_product', 'custom_pwb_product_post_type_rewrite' );
function custom_pwb_product_post_type_rewrite($data){
$data['rewrite']['slug'] = $data['rewrite']['slug'] . '/%pwb-brand%';
$data['rewrite']['with_front'] = false;
return $data;
}
add_filter( 'post_type_link', 'custom_pwb_add_brand_name_in_url', 10, 2 );
function custom_pwb_add_brand_name_in_url( $permalink, $post ) {
if( $post->post_type == 'product' ) {
$term = 'product';
$brands = wp_get_post_terms( $post->ID, 'pwb-brand' );
if( ! empty( $brands ) && ! is_wp_error( $brands ) ) $term = current( $brands )->slug;
$permalink = str_replace( '%pwb-brand%', $term, $permalink );
}
return $permalink;
}
Your urls can now looks like: https://www.bcgel.co.uk/shop/moroccanoil/moroccanoil-treatment-light-100ml/
for example (assuming that ‘shop’ is the base)
??