标签:
步骤: 1,安装custom post template插件。WP下载:点我
2. 复制single.php并重命名,例如single-new.php
3、打开重命名的文件 ,在顶部添加代码
<?php /* Template Name Posts: new */ ?>
还有一种是用函数指定分类文章模板:点我
add_action(‘template_include‘, ‘load_single_template‘); function load_single_template($template) { $new_template = ‘‘; // single post template if( is_single() ) { global $post; // ‘wordpress‘ is category slugs if( has_term(‘wordpress‘, ‘category‘, $post) ) { // use template file single-wordpress.php $new_template = locate_template(array(‘single-wordpress.php‘ )); } } return (‘‘ != $new_template) ? $new_template : $template; }
标签:
原文地址:http://my.oschina.net/sikou/blog/517655