I'm trying to change the permalink structure of the terms for a custom taxonomy, but it's returning page 404. I want the URL to be: example.com/products/category/category-name.
I tried to use the term_link filter, I even tried to put a slug different from the custom post type, however, without success. I have also updated wp_options on permanent links
add_action( 'init', 'register_sps_products_post_type' ); function register_sps_products_post_type() { register_post_type( 'sps-product', array( 'labels' => array( 'name' => 'Products', 'menu_name' => 'Product Manager', 'singular_name' => 'Product', 'all_items' => 'All Products' ), 'public' => true, 'publicly_queryable' => true, 'show_ui' => true, 'show_in_menu' => true, 'show_in_nav_menus' => true, 'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'comments', 'post-formats', 'revisions' ), 'hierarchical' => false, 'has_archive' => 'products', 'taxonomies' => array('product-category'), 'rewrite' => array( 'slug' => 'products' ) ) ); register_taxonomy( 'product-category', array( 'sps-product' ), array( 'labels' => array( 'name' => 'Product Categories', 'menu_name' => 'Product Categories', 'singular_name' => 'Product Category', 'all_items' => 'All Categories' ), 'public' => true, 'hierarchical' => true, 'show_ui' => true, 'rewrite' => array( 'slug' => '%sps-product%/category', 'with_front' => false ), ) ); } add_filter('term_link', 'idinheiro_permalink_archive_cpt', 10, 2); function idinheiro_permalink_archive_cpt( $url ) { if ( false !== strpos( $url, '%sps-product%') ) { $url = str_replace( '%sps-product%', 'products', $url ); } return $url; }