Twenty Thirteen首页显示摘要最简单方法

Twenty Thirteen首页显示摘要最简单方法首页显示摘要最简单方法:修改content.php即可。

随着WordPress 3.6的发布,同时也发布了一个新的官方主题twentythirteen。但是twentytwelve与以前的官方主题一样,首页是显示全文的。我想首页显示摘要,这样页面看起来干净一些。下面是简单的方法。

首先说明一点,建议利用子主题修改默认的twentythirteen主题。

在主题文件夹打开content.php,找到如下代码

  1. <?php if ( is_search() ) : // Only display Excerpts for Search ?>
这段代码以及下面的代码是说只在搜索结果时显示摘要,因此,把上面的代码修改成如下代码即可。
  1. <?php if ( is_search() || is_home() || is_category () || is_author() || is_tag() || is_archive() ) : // 全部以摘要显示?>
如果是利用子主题,把content.php复制到子主题文件夹修改即可。

其实这与Twentytwelve首页显示摘要最简单方法一样。

进行上面的步骤后,首页直接摘要显示。

但是没有「继续阅读」,因此可以继续为Twentythirteen添加继续阅读。

打开子主题function.php文件,加入如下代码即可

  1. <?php
  2. // Add 140x140 image size
  3. add_image_size('excerpt-thumbnail', 140, 140, true);
  4. // Remove the ... from excerpt and change the text
  5. function change_excerpt_more()
  6. {
  7. function new_excerpt_more($more)
  8. {
  9. // Use .read-more to style the link
  10. return '<span class="read-more"> <a href="' . get_permalink($post->ID) . '">继续阅读&raquo;</a></span>';
  11. }
  12. add_filter('excerpt_more', 'new_excerpt_more');
  13. }
  14. add_action('after_setup_theme', 'change_excerpt_more');

评论

此博客中的热门博文

PDF-XChange Viewer Pro (2.5.322.8) 中文绿色增强特别版

EndNote在Word中插入图表方法

如何在网上找到一名专家的简历

MEDLINE,EMBASE,PubMed,PMC,OVID的区别和联系

Endnote X7 新功能简介