/**
*使子分类的category页面渲染父category页面的模板
*/
add_filter('category_template', 'f_category_template');
function f_category_template($template){
$category = get_queried_object();
if($category->parent !='0'){
while($category->parent !='0'){
$category = get_category($category->parent);
}
}
$templates = array();
if ( $category ) {
$templates[] = "category-{$category->slug}.php";
$templates[] = "category-{$category->term_id}.php";
}
$templates[] = 'category.php';
return locate_template( $templates );
}
wordpress 使子分类的category页面渲染父category页面的模板
最新推荐文章于 2023-05-14 14:42:29 发布