Last active
February 13, 2019 21:33
-
-
Save moxdev/d58e5170f69201bab739af3575f1bb41 to your computer and use it in GitHub Desktop.
Remove Taxonomy Slug From URL #wp
This file contains hidden or 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
add_filter( 'term_link', 'remove_tax_slug_link', 10, 3 ); | |
/** | |
* Used to remove or edit the taxonomy in the url for custom urls | |
* uses term_link filter | |
* @link https://codex.wordpress.org/Plugin_API/Filter_Reference/term_link | |
* | |
* @param [type] $link URL link. | |
* @param [type] $term Taxonomy term. | |
* @param [type] $taxonomy Taxonomy. | |
* @return string | |
*/ | |
function remove_tax_slug_link( $link, $term, $taxonomy ) { | |
if ( 'property_locations' !== $taxonomy ) { | |
return $link; | |
} | |
return str_replace( 'property_locations/', '', $link ); // edit 'property_locations/' to be what you want it to be | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment