<?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;