dmjoyce92
Forum Replies Created
-
Forum: Plugins
In reply to: [Custom Post Type UI] Taxonomy rewrite same as custom post type slugAh, 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
Forum: Plugins
In reply to: [Custom Post Type UI] Taxonomy rewrite same as custom post type slugThanks 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