以下函数从slug中删除子类别,但是什么代码集成以删除父类别?
function wpse147453_remove_child_categories_from_permalinks( $category ) {
while ( $category->parent ) {
$category = get_term( $category->parent, 'category' );
}
return $category;
}
add_filter( 'post_link_category', 'wpse147453_remove_child_categories_from_permalinks' );