Created
June 19, 2021 21:00
-
-
Save WProbot/47849c5f6e77589ed53e0330c1ad06cd 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
function remove_category( $string, $type ) { | |
if ( $type != 'single' && $type == 'category' && ( strpos( $string, 'category' ) !== false ) ) { | |
$url_without_category = str_replace( "/category/", "/", $string ); | |
return trailingslashit( $url_without_category ); | |
} | |
return $string; | |
} | |
add_filter( 'user_trailingslashit', 'remove_category', 100, 2); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment