<?php $this->widget('Widget_Contents_Post_Recent')->to($post); ?> <?php while($post->next()): ?> <a href=”<? php $post->permalink(); ?>” title=”<? php $post->title(); ?>”> <?php $post->title(25, '…'); ?></ a> <?php endwhile; ?>
//Popular articles call by laozuo.org function getHotComments($limit = 10){ $db = Typecho_Db:: get(); $result = $db->fetchAll($db->select()->from('table.contents') ->where('status = ?','publish') ->where('type = ?', 'post') ->Where ('created<=unix_timestamp (now()) ','post')//Add this sentence to avoid early exposure of articles that have not reached the time limit ->limit($limit) ->order('commentsNum', Typecho_Db::SORT_DESC) ); if($result){ 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>'; } } }
<?php getHotComments('10');?>
<?php $this->related(5)->to($relatedPosts); ?> <ul> <?php while ($relatedPosts->next()): ?> <li><a href="<?php%20$relatedPosts->permalink();%20?>" title="<?php $relatedPosts->title(); ?>"><? php $relatedPosts->title(); ?></ a></li> <?php endwhile; ?> </ul>