WordPress中Twenty Twelve主题如何设置首页只显示文章摘要

内容纲要

打开Twenty Twelve主题中的content.php文件,比如我的文件路径为:/www/wwwroot/ximouzhao.com/wp-content/themes/twentytwelve,找到第45行注释更改成如下代码
原来代码

        <div class="entry-content">
            <?php the_content( __( 'Continue reading <span class="meta-nav">→</span>', 'twentytwelve' ) ); ?>
            <?php
            wp_link_pages(
                array(
                    'before' => '<div class="page-links">' . __( 'Pages:', 'twentytwelve' ),
                    'after'  => '</div>',
                )
            );
            ?>
        </div><!-- .entry-content -->

我修改后的代码:

        <div class="entry-content">
            <?php if ( is_single() ) {
                    the_content( __( 'Continue reading <span class="meta-nav">→</span>', 'twentytwelve' ) );
                }else {
                   the_excerpt( __( 'Continue reading <span class="meta-nav">→</span>', 'twentytwelve' ) );
               }?>
            <?php
            wp_link_pages(
                array(
                    'before' => '<div class="page-links">' . __( 'Pages:', 'twentytwelve' ),
                    'after'  => '</div>',
                )
            );
            ?>
        </div><!-- .entry-content -->

参考链接:
https://zhidao.baidu.com/question/390439629934679645.html
https://mp.weixin.qq.com/s/762WGa7iY7q-47Gv8CZeLA

WordPress中Twenty Twelve主题如何设置首页只显示文章摘要

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注

滚动到顶部