Zblog calls the code of the previous and next articles of the same category

Exhibition of works zero two hundred and ninety-two

The previous and next articles on the content page of zblog articles are called according to the publication time of the article. In order to improve the relevance of the page content and the optimization of zblog seo, we usually choose to call the previous and next articles in the same category. Unfortunately, zblog does not provide corresponding tag code, so we need to write additional code to implement it.

 Zblog calls the code of the previous and next articles of the same category

The following code extracts the zblog plug-in TcClassPost, which implements the function of calling the previous and next articles in the same category.

Put the code in the include.php file of the theme:

PHP
 function qiteen_ Post_ Prev(&$getthis) { global $zbp; $prev=$getthis; $articles = $zbp->GetPostList( array('*'), array(array('=', 'log_Type', 0), array('=', 'log_CateID', $prev->Category->ID),array('=', 'log_Status', 0), array('<', 'log_PostTime', $prev->PostTime)), array('log_PostTime' => 'DESC'), array(1), null ); if (count($articles) == 1) { return $articles[0]; } else { return null; }} function qiteen_ Post_ Next(&$getthis) { global $zbp; $prev=$getthis; $articles = $zbp->GetPostList( array('*'), array(array('=', 'log_Type', 0), array('=', 'log_CateID', $prev->Category->ID),array('=', 'log_Status', 0), array('>', 'log_PostTime', $prev->PostTime)), array('log_PostTime' => 'ASC'), array(1), null ); if (count($articles) == 1) { return $articles[0]; } else { return null; }}

Find in the include.php file ActivePlugin_ Add the following code to the function:

PHP
 Add_ Filter_ Plugin('Filter_Plugin_Post_Prev', 'qiteen_Post_Prev'); Add_ Filter_ Plugin('Filter_Plugin_Post_Next', 'qiteen_Post_Next');

If the topic did not call the code of the previous or next article, you need to add code in the post-single.php file (if you do not have this file, you can try to add it in the single.php file):

PHP
 {if $article. Prev}<p>Previous:<a href="{$article. Prev. Url}" title="{$article. Prev. Title}">{$article. Prev. Title}</a></p>{/if} {if $article. Text}<p>Next:<a href="{$article. Text. Url}" title="{$article. Text. Title}">{$article. Text. Title}</a></p>{/if}}

Save it.

Related recommendations:

Message from netizens:

I would like to comment:

◎ Welcome to participate in the discussion. Please express your views and exchange your views here.
 Verification Code