WP一个功能的实现:关于摘要跟分页的功能实现(1)

WP中好像不可以实现自动判断文章是否有摘要来显示摘要或者整编文章(我真的没看到,可能是我火星,没看到>_<!),不过我们是有办法实现的。(->_<-不要说我方法笨)

程序过程:首页显示日志时,有摘要的日志显示摘要并且有超链接提示“阅读全文”,没有的显示全文并且提示“全文已完”,单独查看一篇日志的时候,文章全部显示,无链接提示(正常的日志加评论页)

实现过程:>_<!非常简单,就一句语言,将替换模板(通常是主题模块中的index.php)中

the_content();

替换为:

if(!is_single()){
if (!has_excerpt()){ 
  the_content(); 
  $mgs="&gt;&gt;全文已完!";
   } 
else { 
   the_excerpt();
   $mgs="&gt;&gt;阅读全文...";
   } 
$plink="<div style='text-align:right'><a href='".post_permalink()."'>".$mgs."</a></div>";
echo $plink ;
}
else{
the_content();
}

今天无意中发现了WP有一个分页标签的功能:就是在编写文章时需要分页的地方打上<!–nextpage–>,写一个这样的语句就分两页,很方便。

但是却产生了些问题,下篇文章将介绍我自己实现他的方法。

5 Responses to WP一个功能的实现:关于摘要跟分页... »

  1. nwgale 评论 2008-08-24 10:05

    这是更改模板里INDEX的办法,如果我想在BLOG之外的页面调用呢?

    比如wp安装在 /blog/里。
    现在想用 /default.php来调用blog的摘要….

    有什么好办法么?

    回复

    joe 回复 八月 24th, 2008 at 10:18

    :!: ==我试一下

    回复

    joe 回复 八月 24th, 2008 at 10:31

    :wink: 有办法解决的~我写篇日志说明一下,这里说不清楚

    回复

  2. wsgeuv 评论 2008-09-11 20:41

    cuvgwonezonfnilsgvkmzoyxkepsdo

    回复

    joe 回复 九月 11th, 2008 at 20:45

    :?: ????

    回复

Leave a Reply

Email address is not published

You should say a Chinese word to pass spam check. If you can not input Chinese, just copy 你好 and paste them into comment text box.