Toolonomy Logo
Last Updated on: September 18, 2020

Remove Post Base Slug from Taxonomy URLs [PHP Snippet]

If your WordPress site has a custom permalink structure but you don't want that default base slug for the taxonomy pages then use this code snippet to remove it.

/* Advanced Scripts Method to Add This Snippet */
/* 
Title: Remove Post Base Slug from Taxonomy URLs
Type: PHP: Custom Code
Location: Plugins Loaded
Priority: 10
*/

add_filter( 'register_taxonomy_args', function( $args, $taxonomy )
{
if( 'category' === $taxonomy && is_array( $args ) )
$args['rewrite']['with_front'] = false;
return $args;
}, 99, 2 );

Become a Toolonomy Community Member for Free!

Consider joining our Official Community Group if you want to get access to the exclusive insider content and information around the Exclusive Business Development Tools. Also, you will be able to get involved in interesting group discussions with like-minded people that are interested in similar topics as you.
Free Membership
Made with ❤ for Digital Entrepreneurs
Copyright © 2018 - 2022 SyncWin | All Rights Reserved.
Top crossmenu