Hello, I’m trying to add IDs to my custom terms permalinks. The idea is that instead of
/folders/cool-folder
I’d instead have
/folders/123/cool-folder
Where 123 is the term ID.
I managed to accomplish this with this code in `init`:
add_rewrite_tag(“%folder_id%”, ‘([0-9]+)’, “taxonomy=”.$taxonomy_name.”&tag_id=” );
add_rewrite_tag(“%$taxonomy_name%”, ‘([^/]+)’, “taxonomy=”.$taxonomy_name.”&term=” );
$rewrite_args = array();
$rewrite_struct = “folders/%folder_id%/%$taxonomy_name%”;
add_permastruct($taxonomy_name, $rewrite_struct, $rewrite_args);
**The problem:** I get a 404 error if the ID and slug don’t match exactly, e.g.
/folders/123/kool-foolder
/folders/123/asdasdad
/folders/123/
/folders/123
How can I redirect these to the canonical with ID and slug?
[ad_2]