一、隐藏主题主者
第一步:注释或删除作者显示函数:
twentysixteen_entry_meta()
第二步:修改article{margin-bottom:3.5em;}
第三步:设置文章显示宽度:
entry-content {width: 100%;
twentysixteen主题非常不错,只是让作者时间日期占据左侧,占据左侧空间,压缩了文章内容的显示宽度。
放在底部多好。实现方法如下:
1、打开\wp-content\themes\twentysixteen\template-parts目录下的两个文件:
-
- content.php
- content-single.php
注释掉twentysixteen_entry_meta();这个函数调用。
2、修改\wp-content\themes\twentysixteen\style.css文件,
3465行左右 :
/*默认:*/
.site-main > article {margin-bottom: 7.0em;}
/*修改为:*/
.site-main > article {margin-bottom: 3.5em;}
3572行左右 :
/*默认:*/
body:not(.search-results) article:not(.type-page) .entry-content {float: right;width:71.42857144%;}
/*修改为:*/
body:not(.search-results) article:not(.type-page) .entry-content {float: right;width: 100%;}
修改值如:margin-bottom: 3.5em;及width: 100%;,可依据自己实际需求修改。
二、去掉主题特色图片
注释掉:
<?php the_post_thumbnail(); ?>
三、首页显示文章摘要
去主题编辑器,修改该文件代码:template-parts/content.php
<span class="token php language-php"><span class="token delimiter important"><?php</span>
<span class="token function">the_content</span><span class="token punctuation">(</span>
<span class="token function">sprintf</span><span class="token punctuation">(</span>
<span class="token comment">// translators: %s: Post title. </span>
<span class="token function">__</span><span class="token punctuation">(</span> <span class="token single-quoted-string string">'Continue reading<span class="screen-reader-text"> "%s"</span>'</span><span class="token punctuation">,</span> <span class="token single-quoted-string string">'twentysixteen'</span> <span class="token punctuation">)</span><span class="token punctuation">,</span>
<span class="token function">get_the_title</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
<span class="token punctuation">)</span>
<span class="token punctuation">)</span><span class="token punctuation">;</span>
</span>
注释掉,更改为:
<span class="token keyword">if</span><span class="token punctuation">(</span><span class="token operator">!</span><span class="token function">is_single</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
<span class="token function">the_excerpt</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span> <span class="token keyword">else</span> <span class="token punctuation">{</span>
<span class="token function">the_content</span><span class="token punctuation">(</span><span class="token function">__</span><span class="token punctuation">(</span><span class="token single-quoted-string string">'(more…)'</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
四、 优化文章描述
WP 给摘要的默认 55 个字,进入 functions.php,增加 filter,将其中的 55,改为 150 即可。
/* Excerpt Words */ function my_excerpt_length($length) { return 150; } add_filter('excerpt_length', 'my_excerpt_length');