Last active
August 17, 2018 04:20
-
-
Save omniacode/1ae5bbde9c516688e19dfd8b1a8de99d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Remove Taxonomy Slug | |
add_filter( 'term_link', 'remove_tax_slug_link', 10, 3 ); | |
function remove_tax_slug_link( $link, $term, $taxonomy ) { | |
if ( $taxonomy !== 'your-taxonomy-name' ) | |
return $link; | |
return str_replace( 'your-taxonomy-name/', '', $link ); | |
} | |
add_action('init', 'custom_tax_rewrite_rule', 10, 0); | |
function custom_tax_rewrite_rule() { | |
$cats = get_terms( | |
'your-taxonomy-name', array( | |
'hide_empty' => false, | |
) | |
); | |
if( sizeof($cats) ) | |
foreach( $cats as $cat ) | |
add_rewrite_rule( $cat->slug.'/?$', 'index.php?your-taxonomy-name='.$cat->slug, 'top' ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment