function.php 文件中添加如下代码:

function theNext($widget, $default = NULL)
{
@$mid=intval($widget->categories[0]['mid']);
$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')
->join('table.relationships', 'table.contents.cid = table.relationships.cid')
->where('table.relationships.mid = ?', $mid)
->order('table.contents.created', Typecho_Db::SORT_ASC)
->limit(1);
$content = $db->fetchRow($sql);
if ($content) {
$content = $widget->filter($content);
$link = '<a href="' . $content['permalink'] . '">' . $content['title'] . '</a>';
echo $link;
} else {
echo $default;
}
}

function thePrev($widget, $default = NULL)
{
@$mid=intval($widget->categories[0]['mid']);
$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')
->join('table.relationships', 'table.contents.cid = table.relationships.cid')
->where('table.relationships.mid = ?', $mid)
->order('table.contents.created', Typecho_Db::SORT_DESC)
->limit(1);
$content = $db->fetchRow($sql);
if ($content) {
$content = $widget->filter($content);
$link = '<a href="' . $content['permalink'] . '">' . $content['title'] . '</a>';
echo $link;
} else {
echo $default;
}
}

post.php 文件中添加如下调用代码:

<?php thePrev($this); ?>
<?php theNext($this); ?>