Call related articles

When I first started using typecho, I was not familiar with it, and I did not know how to use some functions. Here, we will briefly introduce how to use the related article function to facilitate friends who just contact typecho to modify the template. Related article function

Open the post.php file in the folder of the template you want to modify with a text editor or the appearance of the website background:

 <? php  $this -> related ( five ) -> to ( $relatedPosts ) ;  ?> <ul> <? php  while  ( $relatedPosts -> next ( ) ) :  ?> <li><a href=" <? php  $relatedPosts -> permalink ( ) ;  ?> " title=" <? php  $relatedPosts -> title ( ) ;  ?> "> <? php  $relatedPosts -> title ( ) ;  ?> </a></li> <? php  endwhile ;  ?> </ul>

Paste the above content to the position where you want to add related articles (for example, I put it at the end of the article), and then save it.

Related article Function description

Call method

 $this -> related ( $limits ,  $type ) ;

This function has two parameters:

Parameter name explain
$limits The default value is 5, indicating the number of relevant articles displayed
$type The default value is NULL, which indicates the relevant method of the article. Only author is accepted. When $type is author, relevant articles will be displayed according to the user; For other values, related articles are displayed according to the label.

I hope it will be useful to everyone.

Source: Typecho related article call and function description , by HJin.me. (Some contents are modified)

Print/Export
language
  ?