Habari相关评论的插件,名字叫RN Related Posts,作者是天佑,下载和详细信息看这儿.
使用方法很简单,在需要显示的地方插入这行代码即可:
<?php echo $related_posts; ?>
这儿写下适合我这个主题的用法,可以作为参考.
我的目标是在sidebar中显示"相关文章",并且只有在显示独立文章页面时sidebar中才出现"相关文章",排版格式符合整体界面.
1)上传related.png小图标到模板的images文件夹.
2)修改插件文件relatedposts.plugin.php的action_add_template_vars函数,改成如下形式:
- public function action_add_template_vars( $theme, $handler_vars )
- {
- // Get the related posts only if config is setup properly and during
- // 'display_post' action
- if ( !empty( $this->config['num_post'] ) && Controller::get_action() == 'display_post' )
- {
- $theme->related_posts= $this->get_related_posts();
- $theme->related_posts= "<h3><img alt="Related Posts" src=".$theme->
- theme_url."/images/related.png /> Related Posts</h3>".$theme->related_posts;
- }
- else {
- $theme->related_posts= '';
- }
- }
3)在CSS中加入:
- div#relatedposts ul{
- style-type:none;
- width:100%;
- text-align:right;
- }
-
- div#relatedposts a:hover {
- border-bottom:2px solid #1ce0e7;
- }
4)在sidebar.php中加入:
- <!--Related Posts-->
- <div id="relatedposts">
- <?php echo $related_posts; ?>
- </div>
完成了.

Related Posts
Tag Cloud
Write a response