如何在slug上删除子节点后删除父类别

时间:2017-10-22 18:52:29

标签: wordpress

以下函数从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' );

0 个答案:

没有答案