Good day, it’s not that CPTUI doesn’t support this type of thing, to certain degrees, because as you can see, you were able to configure things to achieve this setup. What isn’t supporting this is WordPress and the request parsing.
With that permalink structure, it’s going to treat every url like this as if it’s a hierarchical taxonomy. Each post name is going to be assumed to be a child term of bridges-and-structures in your example, and so on.
Assumed to be another term archive, not a post.
http://www.pomonasupply.com/products/bridges-and-structures/aluminum-structures/
Quite often, it’s best not to have these types of details match, for these reasons. Perhaps have the category slug be rewritten to “product-category” instead, for SEO reasons and such, while still enabling enough difference to not have issue with querying data.
Thanks for the reply. I found a way to make the taxonomy rewrite work without killing the single post view: implemented the taxonomy rewrite as a separate mu-plugin instead of doing it through CPTUI. Not sure if it’s the order of the rewrites – between the taxonomy and the custom post types – that was causing the conflict, or what. For other people who face this issue, here is the code I used (pasted into a separate file called taxonomy-rewrites.php, and uploaded to mu-plugins directory):
function rewrite_product_category() {
// get the arguments of the already-registered taxonomy
$product_category_args = get_taxonomy( 'product_category' ); // returns an object
// make changes to the args
// in this example there are three changes
// again, note that it's an object
$product_category_args->show_admin_column = true;
$product_category_args->rewrite['slug'] = 'products';
$product_category_args->rewrite['with_front'] = false;
// re-register the taxonomy
register_taxonomy( 'product_category', 'people', (array) $product_category_args );
}
// hook it up to 11 so that it overrides the original register_taxonomy function
add_action( 'init', 'rewrite_product_category', 11 );
credit to this stackexchange answer:
https://wordpress.stackexchange.com/questions/161788/how-to-modify-a-taxonomy-thats-already-registered
Whatever works in my books.
Some thoughts. I believe you will want to have changed that “people” to “product” from the register_taxonomy() line at the end for your case, as that’s the post type it’s supposed to be assigned to. If you didn’t change this part, I’m wondering if that’s part of why it seems to be working now.
Otherwise, registering with the same taxonomy slug, product_category
in this case, would overwrite the originally registered item, if I’m not mistaken, with the new arguments.
Ah, good catch. I changed ‘people’ to ‘product’ and it seems to still work, so lucky for me I guess. Here is the revised code snippet for anyone else looking to reference:
<?php
/*
* Replace Taxonomy slug with Post Type slug in url
*/
function rewrite_product_category() {
// get the arguments of the already-registered taxonomy
$product_category_args = get_taxonomy( 'product_category' ); // returns an object
// make changes to the args
// in this example there are three changes
// again, note that it's an object
$product_category_args->show_admin_column = true;
$product_category_args->rewrite['slug'] = 'products';
$product_category_args->rewrite['with_front'] = false;
// re-register the taxonomy
register_taxonomy( 'product_category', 'product', (array) $product_category_args );
}
// hook it up to 11 so that it overrides the original register_taxonomy function
add_action( 'init', 'rewrite_product_category', 11 );
Thanks again for your assistance