/**
* 21) Удаляем "слово" category из URL
*/
add_filter('category_link', function($a){
return str_replace( 'category/', '', $a );
}, 99 );
foreach( $categories as $category ) {
$category_nicename = $category->slug;
if ( $category->parent == $category->cat_ID ) {
$category->parent = 0;
} elseif ( $category->parent != 0 ) {
$category_nicename = get_category_parents( $category->parent, false, '/', true ) . $category_nicename;
}
$category_rewrite['('.$category_nicename.')/(?:feed/)?(feed|rdf|rss|rss2|atom)/?$'] = 'index.php?category_name=$matches[1]&feed=$matches[2]';
$category_rewrite["({$category_nicename})/{$wp_rewrite->pagination_base}/?([0-9]{1,})/?$"] = 'index.php?category_name=$matches[1]&paged=$matches[2]';
$category_rewrite['('.$category_nicename.')/?$'] = 'index.php?category_name=$matches[1]';
}