WordPress主题–Twenty Fifteen修改首页和分类目录摘要的方法

Twentyfifteen还是像以前的WordPress官方主题一样,首页以全文的形式展示。 有时候直接想看最近的文章或是摘要都不行,所以需要改以下显示方式。我希望是首页能以摘要的方式显示。 以下是详细的方法: 一、首页显示摘要方法 第一步:在 模板 index.php 找到以下代码片段:
<?php // Start the loop. while ( have_posts() ) : the_post();  /* * Include the Post-Format-specific template for the content. * If you want to override this in a child theme, then include a file * called content-___.php (where ___ is the Post Format name) and that will be used instead. */ get_template_part( ‘content’, get_post_format() );  // End the loop. endwhile;
第二步:将以上代码的content换成content-search ,然后进行保存。
<?php // Start the loop. while ( have_posts() ) : the_post();  /* * Include the Post-Format-specific template for the content. * If you want to override this in a child theme, then include a file * called content-___.php (where ___ is the Post Format name) and that will be used instead. */ get_template_part( ‘content-search’, get_post_format() );  // End the loop. endwhile;
二、分类目录显示摘要方法 第一步:在文章归档 archive.php 文件中找到以下代码:
while ( have_posts() ) : the_post(); /* * Include the Post-Format-specific template for the content. * If you want to override this in a child theme, then include a file * called content-___.php (where ___ is the Post Format name) and that will be used instead. */ get_template_part( ‘content’, get_post_format() ); // End the loop. endwhile;
第二步:把代码上的content改为content-search即可
<?php // Start the Loop. while ( have_posts() ) : the_post(); /* * Include the Post-Format-specific template for the content. * If you want to override this in a child theme, then include a file * called content-___.php (where ___ is the Post Format name) and that will be used instead. */ get_template_part( ‘content-search’, get_post_format() );  // End the loop. endwhile;
转载请注明本文链接:https://blog.weixiaoline.com/975.html

发表评论

您的电子邮箱地址不会被公开。