The method is many, here the small series chooses three kinds, the first kind is zblog the official comparison recommendation method, the code is as follows:
{$aid = $article. ID}
{$tagid = $article. Tags}
{$cid = $article. Category.id}
{PHP}
$str = ';
$TAGRD =array_rand ($tagid);
if (sizeof ($tagid) >0 && ($tagid [$tagrd]->count) >1) {
$tagi = '%{'. $tagrd. '} %';
$where = Array (' = ', ' log_status ', ' 0 '), array (' Like ', ' Log_tag ', $tagi), Array (' <> ', ' log_id ', $aid));
}else{
$where = Array (' = ', ' log_status ', ' 0 '), array (' = ', ' Log_cateid ', $cid), Array (' <> ', ' log_id ', $aid));
}
$array = $zbp->getarticlelist (Array (' * '), $where, Array (' rand () ' => '), Array (6), ');
foreach ($array as $related) {
if (($related->id)!= $aid) {
$str. = "<li><span class=\" time\ ">{$related->time (' m-d ')}</span><span class=\" Title\ "> <i class=\ "icon-doc-text\" ></i><a href=\ "{$related->url}\" title=\ "{$related->title}\" >{$ Related->title}</a></span><small class=\ "pcomm\" ><i class=\ "icon-comment-1\" ></i > <a href=\ "{$related->url} #comments \" rel=\ "nofollow\" title=\ "comments on {$related->title}" >{$ Related->commnums}</a></small></li> ";
}
}
{/php}
{$STR}
The second one uses the zblogphp "GetList" function, the code reads as follows:
{foreach GetList (10,null,null,null,null,null,array (' is_related ' => $article. ID)) as $related}
<li><span>{$related. Time (' y-m-d ')}</span><a href= "{$related. URL} ">{$related. Title}</a></li>
{/foreach}
Place the above code in the "post-single.php" file in the subject you are using, and generally recommend "{$article. Content} "below, you can define CSS yourself."
You can also write the relevant article in the theme of the call code, the code is as follows:
{PHP}
$relatedpad = ';
$relatedtxt = ';
$numm = $zbp->config (' Duxx ')->related;//duxx as the ID of the subject
if (GetList ($numm, Null,null,null,null,null,array (' is_related ' => $article->id))) {
$array = GetList ($numm, Null,null,null,null,null,array (' is_related ' => $article->id));
}else{
$array = GetList ($numm, $article->category->id);
}
foreach ($array as $related) {
Sf_img1::getpics ($related, 181,111,4);
if ($related->sf_img_count>0) {
$rimg = $related->sf_img[0];
}else{
$rimg = $zbp->host ' zb_users/theme/duxx/style/img/random/'. Rand (1,20). JPG ';
}
$relatedpad. = ' <li><a href= '. $related->url. ' title= '. $related->title. ' " >$relatedtxt. = ' <li><a href= '. $related->url. ' title= '. $related->title. ' " ></a></li> ';
}
{/php}
Of course, we can also use the third party "related article" plug-in to replace the zblogphp original related article features. More recommended plug-ins have "Baidu recommended", "Friends recommend". We can choose the relevant article function according to our own demand