常规来说:主要记录上一篇/下一篇的代码
/**
* 显示下一篇
*
* @access public
* @param string $default 如果没有下一篇,显示的默认文字
* @return void
*/
function theNext($widget, $default = NULL)
{
$db = Typecho_Db::get();
$sql = $db->select()->from('table.contents')
->where('table.contents.created > ?', $widget->created)
->where('table.contents.status = ?', 'publish')
->where('table.contents.type = ?', $widget->type)
->where('table.contents.password IS NULL')
->order('table.contents.created', Typecho_Db::SORT_ASC)
->limit(1);
$content = $db->fetchRow($sql);
 
if ($content) {
$content = $widget->filter($content);
$link = '下一篇';
echo $link;
} else {
echo $default;
}
} 
/**
* 显示上一篇
*
* @access public
* @param string $default 如果没有下一篇,显示的默认文字
* @return void
*/
function thePrev($widget, $default = NULL)
{
$db = Typecho_Db::get();
$sql = $db->select()->from('table.contents')
->where('table.contents.created < ?', $widget->created)
->where('table.contents.status = ?', 'publish')
->where('table.contents.type = ?', $widget->type)
->where('table.contents.password IS NULL')
->order('table.contents.created', Typecho_Db::SORT_DESC)
->limit(1);
$content = $db->fetchRow($sql); 
if ($content) {
$content = $widget->filter($content);
$link = '上一篇';
echo $link;
} else {
echo $default;
}
}将以上代码写入functions.php
调用代码如下:
 和 
typecho上一篇下一篇内获取图片封面实例,直接上代码参考把
/**
* 显示下一篇
*
* @access public
* @param string $default 如果没有下一篇,显示的默认文字
* @return void
*/
function theNext($widget, $default = NULL)
{
$db = Typecho_Db::get();
$sql = $db->select()->from('table.contents')
->where('table.contents.created > ?', $widget->created)
->where('table.contents.status = ?', 'publish')
->where('table.contents.type = ?', $widget->type)
->where('table.contents.password IS NULL')
->order('table.contents.created', Typecho_Db::SORT_ASC)
->limit(1);
$content = $db->fetchRow($sql);
if ($content) {
$img =  $db->fetchAll($db->select()->from('table.fields')->where('name = ? AND cid = ?','img',$result['cid']));
 if(count($img) !=0){
  //var_dump($img);
  $img=$img['0']['str_value'];
  if($img){}
  else{
$img="/usr/themes/spimes/images/thumbs/other_thumbnail.png";
  } 
 }
  
 // var_dump($img);
 // if($img == ""){
 //  $img = "wu";
 // }
$content = $widget->filter($content);
$link = '';
echo $link;
} else {
echo $default;
}
}
如果想获取时间的话,这里就需要注意
评论时间就是$content['created'],这是unix时间戳,转换成人类看得懂的时间
date('Y-m-d H:i:s', $content['created_at'])!
发表评论