wordpress 首页文章 设置为只显示摘要

Step1

到wordpress后台,依次选择 外观-->主题编辑器

image

Step2

选择右边的主题文件index.php文件,可以看到语句

<?php while ( have_posts() ) : the_post(); ?>
<?php get_template_part( 'content', get_post_format() ); ?>
<?php endwhile; ?>

可以看出,index.php是嵌套一个 content.php 的文件用于专门显示文章的内容,这就是为什么在首页老是显示文章全文。

Step3

找到content.php,找到代码

<?php
    the_content( __( 'Continue reading <span>→</span>', 'twentyeleven' ) );
?>

修改为

<?php if(!is_single()) {
    the_excerpt();
} else {
    the_content(__('(more…)'));
} ?>

保存

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。