WordPress首页显示文章摘要 基于wp官方主题Twenty Sixteen优化

在WordPress系统中,默认的首页和目录页使用的书全文输出,这对于文章内容较长的博客来说很不方面,下面方法可以简单的实现在WordPress首页和目录页显示摘要而非全文。

去主题编辑器,修改该文件代码:template-parts/content.php第25行代码:

        <?php
            the_content(
                sprintf(
                    // translators: %s: Post title. 
                    __( 'Continue reading<span class="screen-reader-text"> "%s"</span>', 'twentysixteen' ),
                    get_the_title()
                )
            );

注释掉或者删除,更改为:

            if(!is_single()) {
                the_excerpt();
                } else {
                the_content(__('(more…)'));
                } 

保存即可!