让wordpress博客首页分类页显示文章标题列表或摘要

05月 9th, 2008 by 飞龙

  默认的wordpress摘要方式,其实还是一种半自动半手工的活。首先需要在博客后台选项(options)–输出(reading)设置里,把输出方式设为摘要而不是全文;其次还需要你在编辑发表每一篇日志时,光标停留在截取处,然后点击编辑器上一个叫做"split post with more tag" 的按钮(快捷方式是Alt+t )。并且,让人不爽的是,读者在前台点击 more来阅读更多时,却发现更多(read more)链接是一些莫名其妙的后缀,而不是固定静态链接网址。

  所以,这种默认摘要方式,不能让飞龙这种懒博主满意。如何让首页和分类列表页只显示文章标题列表或摘要呢?参考网上一些资料,终于找到了解决办法。飞龙记录在http://feilong.org/index.php/wordpress-no-more-just-title-list,方便以后朋友门参考。

  一 在后台主题管理的index.php文件中找到显示全文的函数: <?php the_content(); ?> 。

  二 这个代码所属div层作用是显示该文摘或文章全文。比如飞龙的该层代码是:
<div class="entry">
<?php the_content(’Read the rest of this entry ?’); ?>
</div>

  将它们替换为:
<div class="entry">
<?php the_excerpt(); ?>
<br>
<a href="<?php the_permalink() ?>" rel="bookmark" title="进入<?php the_title();?>">阅读"<?php the_title(); ?>"全文</a>
</div>

  或替换为:
<div class="entry">
<?php if(is_category() || is_archive() || is_home() ) {
     the_excerpt();
 } else {
     the_content(’Read the rest of this entry ?’);
 } ?>
<div class="details"><div class="inside">
<?php comments_popup_link(’No Comments’,'1 Comment’,'% Comments’); ?> so far | <a href="<?php
the_permalink() ?>">阅读全文?</a></div></div>
</div>

  三 以上方法显示wordpress摘要,其中的<?php the_excerpt(); ?>显示摘要函数。你在编辑发表文章时仍然需要点击编辑器上那个"split post with more tag"按钮(快捷方式是Alt+t )。

  下面探讨如何让wordpress分类列表页只显示文章的标题列表?飞龙左思右想,发现其实很简单:直接把这个层里代码都删掉,只留下:
<div class=”entry”>
</div>

  哈哈成功了!飞龙博客现在主页和分类页的显示效果就是这样,只有文章标题列表,没有摘要或全文,感觉清爽!最后感谢 http://dwgoogle.cn ,你那篇文章对飞龙很有启发;当感谢月光博客
http://www.williamlong.info/archives/1031.html 
;感谢hhalloyy的http://e-spacy.com/blog/wordpress-blog-full-content-excerpt ;感谢fwolf的
http://www.fwolf.com/blog/post/102

  博主:飞龙.org
  链接:http://feilong.org/index.php/wordpress-no-more-just-title-list
  网络资料,朋友共享,http://feilong.org 可加入收藏夹。转载请保留上面文字。

Posted in wordpress, 飞龙原创 | 朋友留言哟!

One Response

  1. 丫丫学语 Says:

    非常感谢飞龙哈哈,你那最后一做法,简直太有意思了,想不到呀。



Leave a Comment

*

*

飞龙: 有什么疑难,有什么建议,有说什么说什么♂


其他朋友在看什么?

分类

最新日志

Links



Google