/**
*使子分类的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页面的模板
最新推荐文章于 2024-10-31 10:35:57 发布
本文介绍了一种WordPress中通过自定义函数实现子分类页面使用父分类页面模板的方法,以此来统一显示样式。
704

被折叠的 条评论
为什么被折叠?



