前段时间LazyNg给了我两个建议叫我修改一下主题。
1.问题:评论栏中的嵌套回复的时候,后一个总是比前一个缩进,如果嵌套多余五层的话,就会发现评论挤到最右边,一行只有一个文字,那样就太搓了。
解决方案:第一个嵌套回复的时候启动缩进,第二个就不用了,直接和前一个保持一致的缩进值就好。
解决方法:修改style.css文件找到,ul.comments ul.children{margin:0 0 0 40px;padding:0;} 这一行,在这一行下面增加一行ul.comments ul.children ul.children{margin:0;} 。其实也可以修改缩进值,缩进的距离小一点就好。看个人的喜好了。
2.问题:评论的楼号问题,本来的是想倒叙显示评论的时候,最后一个留言的人就会出现在第一页的第一个,但是他的楼号还是从1开始的,和正序排序的楼号排序是一样的。
解决方案:一开始只是简单的把楼号从大到小显示出来,但是我发现,当回复给评论者时,新出现的嵌套回复的楼号竟然比上面的那个小,这。。。。所以Lazy建议嵌套回复要么不要使用楼号,要么使用11-1,11-2这样的形式。采纳后一种形式。
解决方法:根据zww的《倒序显示主评论楼层号(支持评论分页)》这篇文章做了修改。按理说一般的显示评论是使用wordpress默认提供的mytheme_comment 回调函数,具体使用方法可以看一下官方解释(http://codex.wordpress.org/Template_Tags/wp_list_comments)。如果想修改的话,要在主题下面的funcitons.php文件中重写mytheme_comment函数。不过检查了Mystique主题后,我发现他是自己写了个函数mystique_list_comments调用,并放在了lib文件夹下的core.php文件中。代码如下,也可下载查看。点此下载。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 | function mystique_list_comments($comment, $args, $depth) { $GLOBALS['comment'] = $comment; // $commentreplycount = 0;//只能放在这里。 global $commentcount,$commentsum,$wpdb,$post,$commentreplycount;//commentsum是总的评论数,commentreplycount是嵌套回复的自增 $commentsum=get_comments_number(); if('desc' == get_option('comment_order')) //倒叙的话只能直接用SQL过滤并统计出主评论数量 { if(!$commentcount) {//初始化楼层计数器 $comments = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_post_ID = $post->ID AND comment_type = '' AND comment_approved = '1' AND !comment_parent"); $cnt = count($comments);//获取主评论总数量cnt $page = get_query_var('cpage');//获取当前评论列表页码 $cpp = get_option('comments_per_page');//获取每页评论显示数量 if( $page == null){ //如果没有开启分页显示评论 $commentcount = $cnt +1; }else if( ceil($cnt / $cpp)==1 || ($page != null && $page>1 && $page==://www.php.net/ceil">ceil($cnt/$cpp))){ $commentcount = $cnt+1;//开启分页评论,如果评论只有1页或者是最后一页,初始值为主评论总数 }else {//如果开启分页,并且有好几页的话 $commentcount = $cpp * $page +1; } } ?> class="comment-head ">
< ?php if(get_option('show_avatars')): ?>
class="avatar-box">< ?php echo mystique_get_avatar($comment->comment_author_email, 48); ?> < ?php endif; ?>
class="author">
< ?php
if (get_comment_author_url()) $authorlink='.get_comment_ID().'" href="'.get_comment_author_url().'" rel="nofollow">'.get_comment_author().'';
else $authorlink='.get_comment_ID().'">'.get_comment_author().'';
$authorlink = apply_filters("mystique_comment_author_link", $authorlink); ?>
class="by">
< ?php if(!$parent_id = $comment->comment_parent )
{
printf(__('%1$s written by %2$s', 'mystique'), '.get_comment_ID().'">#'.--$commentcount.'', $authorlink);
$commentreplycount=0;
}
else
{
printf(__('%1$s written by %2$s', 'mystique'), '.get_comment_ID().'">#'.$commentcount.'-'.++$commentreplycount.'', $authorlink);
}
?>
< ?php echo mystique_timeSince(abs(strtotime($comment->comment_date . " GMT"))); ?> class="controls bubble">
< ?php if (get_mystique_option('jquery') && (comments_open())): ?>
< ?php if(get_option('thread_comments')): ?>
class="reply" id="reply-to-" href="< ?php echo esc_url(add_query_arg('replytocom', $comment->comment_ID)); ?>#respond">< ?php _e("Reply","mystique"); ?>
< ?php endif; ?>
class="quote" title="" href="#respond">< ?php _e('Quote','mystique'); ?>
< ?php endif; ?>
< ?php edit_comment_link('Edit','',''); ?>
class="comment-body clear-block" id="comment-body-">
< ?php if ($comment->comment_approved == '0'): ?>
< ?php
}
elseif( 'asc' == get_option('comment_order'))//正序的话
{
if(!$commentcount){//初始化楼层计数器
//$comments = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_post_ID = $post->ID AND comment_type = '' AND comment_approved = '1' AND !comment_parent");
$page = get_query_var('cpage');
$cpp = get_option('comments_per_page');//获取每页评论数
if( $page == null){//没有开启分页显示
$commentcount=0;
}else{
$commentcount = $cpp * ($page-1);
}
//echo $page.'!!'.$cpp ;
}
?>
class="error">< ?php _e('Your comment is awaiting moderation.','mystique'); ?> < ?php endif; ?>class="comment-text">< ?php comment_text(); ?>
="comment-reply-">
class="comment-head ">
< ?php if(get_option('show_avatars')): ?>
class="avatar-box">< ?php echo mystique_get_avatar($comment->comment_author_email, 48); ?> < ?php endif; ?>
class="author">
< ?php
if (get_comment_author_url()) $authorlink='.get_comment_ID().'" href="'.get_comment_author_url().'" rel="nofollow">'.get_comment_author().'';
else $authorlink='.get_comment_ID().'">'.get_comment_author().'';
$authorlink = apply_filters("mystique_comment_author_link", $authorlink); ?>
class="by">
< ?php if(!$parent_id = $comment->comment_parent )
{
printf(__('%1$s written by %2$s', 'mystique'), '.get_comment_ID().'">#'.++$commentcount.'', $authorlink);
$commentreplycount=0;
}
else
{
printf(__('%1$s written by %2$s', 'mystique'), '.get_comment_ID().'">#'.$commentcount.'-'.++$commentreplycount.'', $authorlink);
}
?>
< ?php echo mystique_timeSince(abs(strtotime($comment->comment_date . " GMT"))); ?> class="controls bubble">
< ?php if (get_mystique_option('jquery') && (comments_open())): ?>
< ?php if(get_option('thread_comments')): ?>
class="reply" id="reply-to-" href="< ?php echo esc_url(add_query_arg('replytocom', $comment->comment_ID)); ?>#respond">< ?php _e("Reply","mystique"); ?>
< ?php endif; ?>
class="quote" title="" href="#respond">< ?php _e('Quote','mystique'); ?>
< ?php endif; ?>
< ?php edit_comment_link('Edit','',''); ?>
class="comment-body clear-block" id="comment-body-">
< ?php if ($comment->comment_approved == '0'): ?>
< ?php
}
} // class="error">< ?php _e('Your comment is awaiting moderation.','mystique'); ?> < ?php endif; ?>class="comment-text">< ?php comment_text(); ?>
="comment-reply-">
|
最后结果的示意图如下。
>> 若为原创,转载请注明: 转载自Laycher's Blog
>> 本文链接地址: 再次修改Mystique主题的评论样式
>> 订阅本站: http://feed.feedsky.com/laycher
have a try
网址速度好慢
还好
你回复的太多了。。。网站速度一直是我的硬伤。。