I want to change woocommerce standard product permalink structure from /product/parent-category/category/product-slug to /parent-category/product-slug . That's my functions.php add_filter( 'woocommerce_product_post_type_link_parent_category_only', '__return_true' ); function na_remove_slug( $post_link, $post, $leavename ) { if ( 'product' != $post->post_type || 'publish' != $post->post_status ) { return $post_link; } $post_link = str_replace( '/product/', '/', $post_link ); return $post_link; } add_filter( 'post_type_link', 'na_remove_slug', 10, 3 ); function change_slug_struct( $query ) { if ( ! $query->is_main_query() || 2 != count( $query->query ) || ! isset( $query->query['page'] ) ) { return; } if ( ! empty( $query->query['name'] ) ) { $query->set( 'post_type', array( 'post', 'product', 'page' ) ); } elseif ( ! empty( $query->query['pagename'] ) && false === strpos( $query->query['pagename'], '/' ) ) { $query->set( 'post_type', array( 'post', 'product', 'page' ) ); // We also need to set the name query var since redirect_guess_404_permalink() relies on it. $query->set( 'name', $query->query['pagename'] ); } } add_action( 'pre_get_posts', 'change_slug_struct', 99 ); And here permalinks settings: enter image description here Urls seems to be okay, after going to archive to urls are correct, but when I go to single product page I get 404. What could be the problem or is there other way to have permalink structure I want? I've tried many plugins but none seems to do what I want