-
-
Save scribu/52b8db30e27ac0b9deef to your computer and use it in GitHub Desktop.
FV Top Level Categories
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
<?php | |
// Add to bottom of top-level-cats.php | |
add_filter('category_link', 'top_level_cats_remove_cat_base'); | |
function top_level_cats_remove_cat_base($link) { | |
$category_base = get_option('category_base'); | |
// WP uses "category/" as the default | |
if ($category_base == '') | |
$category_base = 'category'; | |
// Remove initial slash, if there is one (we remove the trailing slash in the regex replacement and don't want to end up short a slash) | |
if (substr($category_base, 0, 1) == '/') | |
$category_base = substr($category_base, 1); | |
$category_base .= '/'; | |
return preg_replace('|' . $category_base . '|', '', $link, 1); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment