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 );

Explore our Facebook Community

Consider joining our Toolonomy Facebook Community if you want to involve in the group discussion with like-minded people about Business Development Tools.
Join Now
Made with ❤ for Digital Entrepreneurs
Copyright © 2018 - 2022 SyncWin | All Rights Reserved.
Top crossmenu