emlog程序模版文章页面的相邻文章也就是上一篇下一篇文章,默认是按照当前文章相近时间来调用的,从seo优化方面来说,文章的相邻文章最好展示与文章内容相关的文章才好,在不修改emlog程序内核文件前提
<?php //相同分类相邻文章 function lanye_nextprve($date, $sortid){ $db = Database::getInstance(); $nextlog = $db->once_fetch_array("SELECT title,gid FROM " . DB_PREFIX . "blog WHERE date < $date and sortid='$sortid' and hide = 'n' and checked='y' and type='blog' ORDER BY date DESC LIMIT 1"); $prevlog = $db->once_fetch_array("SELECT title,gid FROM " . DB_PREFIX . "blog WHERE date > $date and sortid='$sortid' and hide = 'n' and checked='y' and type='blog' ORDER BY date LIMIT 1"); if($prevlog) { echo '<li>下一篇:<a href="'.Url::log($prevlog['gid']).'" title="'.htmlspecialchars($prevlog['title']).'">'.htmlspecialchars($prevlog['title']).'</a></li>'; }else{ echo '<li>上一篇:没有了</li>'; } if($nextlog) { echo '<li>下一篇:<a href="'.Url::log($nextlog['gid']).'" title="'.htmlspecialchars($nextlog['title']).'">'.htmlspecialchars($nextlog['title']).'</a></li>'; }else{ echo '<li>下一篇:没有了</li>'; } }?> 调用代码 <?php lanye_nextprve($date, $sortid);?>
粉丝
0
关注
0
收藏
0