操作步骤:
1、把下面的代码添加到主题的functions.php文件:
function boke8GetIdPosts($id){
if($id){
$getid = explode(',',$id);
$db = Typecho_Db::get();
$result = $db->fetchAll($db->select()->from('table.contents')
->where('status = ?','publish')
->where('type = ?', 'post')
->where('cid in ?',$getid)
->order('cid', Typecho_Db::SORT_DESC)
);
if($result){
$i=1;
foreach($result as $val){
$val = Typecho_Widget::widget('Widget_Abstract_Contents')->push($val);
$post_title = htmlspecialchars($val['title']);
$permalink = $val['permalink'];
echo '<li><a href="'.$permalink.'" title="'.$post_title.'" target="_blank">'.$post_title.'</a></li>';
}
}
}else{
echo '请设置要调用的文章ID';
}}
2、在要显示文章位置对应的模板文件添加以下调用代码:
<?php boke8GetIdPosts('1,4,6');?>
其中1,4,6是要调用的文章id,修改为自己要调用的文章id即可,多个id用英文逗号隔开。