深圳网站设计制作nba交易最新消息汇总
1、get_template_part()函数用法
get_template_part()函数的使用很灵活,不仅仅是加载一个模板文件进来,而且还有备用的选项,调用代码如下:
<?php get_template_part( $slug, $name ); ?>
参数:
$slug (必须) 通用的模板名
$name (可选) 指定的模板名
什么意思呢?我们来看一下具体的示例:
<?php get_template_part( 'content', 'blog' ); ?>
意思是说,如果content-blog.php存在,则调用content-blog.php,否则,就调用content.php
2、首页摘要字数控制
方法一:找到content.php文件并打开他,找到the_content()这个函数,定位到那个位置之后,将下面代码插入:
<?php if(is_category() || is_archive() || is_home() ){the_excerpt();}else{the_content( __( 'Continue reading <span class="meta-nav">→</span>', 'twentytwelve' ) );} ?>
然后将刚刚查询到的the_content()函数中的代码替换到上方代码中的the_content()
方法二:
或者< ?php the_content(); ?>
修改为:< ?php the_excerpt(); ?>
方法三:
formatting.php文件,然后找到这行代码:$excerpt_length = 55;