在使用WordPress的2014官方主题(Twenty Fourteen)时,如果在WordPress首页显示每一篇日志的全文,会让首页变得很杂乱、庸常。
但这个主题中无法通过“设置”来设定首页显示文章摘要,其实可以通过修改以下内容来实现WordPress首页显示文章摘要的效果:
进入“外观”-〉“编辑”,选择“content.php”,将下面代码:
<?phpif( is_search()):?> <divclass="entry-summary"> <?php the_excerpt();?> </div><!-- .entry-summary --> <?phpelse:?> <divclass="entry-content"> <?php the_content( __('Continue reading <span class="meta-nav">→</span>','twentyfourteen')); wp_link_pages(array( 'before'=>'<div class="page-links"><span class="page-links-title">'. __('Pages:','twentyfourteen').'</span>', 'after'=>'</div>', 'link_before'=>'<span>', 'link_after'=>'</span>', )); ?> </div><!-- .entry-content --> <?phpendif;?>
替换为:
<?phpif( is_single()):// Only display full content for Single page ?> <divclass="entry-content"> <?php the_content( __('Continue reading <span class="meta-nav">→</span>','twentyfourteen')); wp_link_pages(array( 'before'=>'<div class="page-links"><span class="page-links-title">'. __('Pages:','twentyfourteen').'</span>', 'after'=>'</div>', 'link_before'=>'<span>', 'link_after'=>'</span>', )); ?> </div><!-- .entry-content --> <?phpelse:?> <divclass="entry-summary"> <?php the_excerpt();?> </div><!-- .entry-summary --> <?phpendif;?>