飞龙博客

feilong.org

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

feilong.org 修订于2008-05-09 08:53:01 760 次浏览

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

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

一、在后台主题管理准备编辑主题文件index.php,ctrl+F,找到wordpress调用和显示全文函数:<?php the_content(); ?>

二、这个代码一般外层带div,用来调整显示该文摘或全文的css样式,比如飞龙的该层代码是:
<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();?>" >阅读全文</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">
<?php comments_popup_link('No Comments','1 Comment','% Comments'); ?> so far | <a href="<?php the_permalink() ?>">阅读全文</a>
</div>

</div>

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

四、下面探讨如何让wordpress分类列表页只显示文章的标题列表?

飞龙左思右想,发现其实很简单:直接把这个层里代码都删掉,只留下:
<div class=”entry”>
</div>

哈哈成功了!飞龙博客现在主页和分类页的显示效果就是这样,只有文章标题列表,没有摘要或全文,感觉清爽!飞龙补充,你也可以把这个div层都删除,看你css功底如何了。若转载本文请保留版权!

最后感谢 http://dwgoogle.cn 你那篇文章对飞龙很有启发;还要感谢月光博客 www.williamlong.info/archives/1031.html 还有hhalloyy的http://e-spacy.com/blog/wordpress-blog-full-content-excerpt 感谢fwolf的 www.fwolf.com/blog/post/102

更新网址:https://feilong.org/wordpress-no-more-just-title-list
最初发布:20080509 08:53:01 feilong.org 于广州

加入收藏夹,查看更方便。

所在分类: wordpress

新作:

旧文:

AI音乐 blog money bui 教程 echarts 教程 eclipse 教程 html css 教程 IT趋势 js 教程 json 教程 mysql 教程 nodejs npm 教程 onblog SQLite 教程 tutorials vscode 教程 wap网站 winpe启动盘 wordpress 主机推荐 人工智能 前端开发 博客 名企名网 域名注册 常用软件 建站程序 操作系统 教程 数码 无线上网 日记 电子商务 电脑笔记本 网站 网站优化 网站开发 网站推广 网站策划 网络 虚拟现实 默认