首页 WordPress教程 WordPress子分类页面使用父分类页面模板
正文 评论

WordPress子分类页面使用父分类页面模板

在我们开发Wordpress主题的时候,我们会希望子分类继续使用父分类的页面模板,这样能大大减少我们的工作量。

那么WordPress子分类页面如何使用父页面模板呢?

这篇Wordpress教程详细为你解答。

//WordPress子分类页面使用父页面模板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 );}

使用教程

将上面代码复制到主题的functions.php页面即可。

扫码关注wp主题君

精选优质免费WordPress主题模板,分享最新WordPress实用建站教程!

记住我们的网址:ztJun.com

-=||=-收藏赞 (0)
更多主题
单栏极简文艺WordPress博客主题:Diaspora主题
¥ 0 关注:21,681
详情
v1.0.0
小程序收录免费WordPress主题:XCX主题
¥ 0 关注:21,681
详情
简约黑白WordPress个人博客主题:Personal主题
¥ 0 关注:21,314
详情
v1.0.0
一款简约单栏的免费WordPress博客主题:itheme主题
¥ 0 关注:19,265
详情
功能丰富切轻量的WordPress虚拟资源主题:Rizhuti主题
¥ 599 关注:19,240
详情
v3.4.0
适用自媒体资讯的免费WordPress主题:Autumn主题
¥ 0 关注:16,484
详情
回复
暂无评论

不要再留垃圾评论了,主题君整理资源不容易,留几句鼓励的话吧。