傻大憨

wordpress根据文章分类自动调用指定页面模板

通过wordpress分类目录的别名来调用指定的single模板

 add_action('template_include', 'load_single_template');
 function load_single_template($template) {
 $new_template = '';
 if( is_single() ) {
 global $post;
 // 新闻
 if( has_term('news', 'category', $post) ) {
 $new_template = locate_template(array('single-newsinfo.php' ));
        }
 // 团队
 if( has_term('team', 'category', $post) ) {
 $new_template = locate_template(array('single-team.php' ));
        }
 // 案例
 if( has_term('case', 'category', $post) ) {
 $new_template = locate_template(array('single-case.php' ));
        }
 // 产品
 if( has_term('product', 'category', $post) ) {
 $new_template = locate_template(array('single-product.php' ));
        }
     }
 return ('' != $new_template) ? $new_template : $template;
 }

把上面的代码,添加到functions.php文件中即可。

Published
Categorized as 建站知识 Tagged ,

By 傻大憨

shadahan.com是一个关注跨境电商、创业话题的网站。

GGD独立站受跨境电商青睐的主要原因

GGD独立站成为更多企业实现品牌出海、业务增长的重要选择,助力企业在全球市场竞争中脱颖而出。

为古腾堡而生的轻量化建站解决方案

简站WordPress主题是一款与古腾堡编辑器配合最默契、使用体验最流畅的轻量级解决方案。

WordPress子页面调用父页面标题

在子页面显示父页面的标题

wordpress 禁止后台编辑主题

禁止后台编辑主题和插件文件,只需要在wp-config.php中添加以下代码即可。

外贸网站要不止于“好看” 更要“能接单”

外贸建站(waimao-jianzhan.com)是一家深耕外贸领域多年的专业网站建设服务商,专注于为出口型企业提供全球化、专业化、高转化的外贸营销型网站建设服务。

跨境电商独立站建完后没客户怎么办

跨境电商独立站建完后如果没有客户,可以采取以下策略来解决。可以逐步提升独立站的流量和订单量,从而解决没有客户的困境。