好的,我真的不知道如何帮助您解决您的特殊问题,但我可以为您的自定义评论模板提供一些指导,该模板运行完美!我使用 ThemeShaper http://themeshaper.com/2009/07/01/wordpress-theme-comments-template-tutorial/的 Ian Stewart 教程制作我的评论模板。首先,comments.php 文件如下所示:
<?php
/**
* @package WordPress
* @subpackage Default_Theme
*/
// Do not delete these lines
if (!empty($_SERVER['SCRIPT_FILENAME']) && 'comments.php' == basename($_SERVER['SCRIPT_FILENAME']))
die ('Please do not load this page directly. Thanks!');
if ( post_password_required() ) { ?>
<p class="nocomments">This post is password protected. Enter the password to view comments.</p>
<?php
return;
}
?>
<!-- You can start editing here. -->
<?php if ( have_comments() ) : ?>
<h3 id="comments"><?php comments_number('No hay Respuestas', 'Hay 1 Respuesta', 'Hay % Respuestas' );?></h3>
<ol class="commentlist">
<?php wp_list_comments('type=comment&callback=advanced_comment'); //this is the important part that ensures we call our custom comment layout defined above
?>
</ol>
<div class="clear"></div>
<div class="comment-navigation">
<div class="older"><?php previous_comments_link() ?></div>
<div class="newer"><?php next_comments_link() ?></div>
</div>
<?php else : // this is displayed if there are no comments so far ?>
<?php if ( comments_open() ) : ?>
<!-- If comments are open, but there are no comments. -->
<?php else : // comments are closed ?>
<!-- If comments are closed. -->
<p class="nocomments">Los comentarios están cerrados.</p>
<?php endif; ?>
<?php endif; ?>
<?php if ( comments_open() ) : ?>
<div id="respond">
<h3><?php comment_form_title( 'Comentar', 'Responder %s' ); ?></h3>
<div class="cancel-comment-reply">
<small><?php cancel_comment_reply_link(); ?></small>
</div>
<?php if ( get_option('comment_registration') && !is_user_logged_in() ) : ?>
<p>Debes iniciar sesión para poder comentar.</p>
<a href="http://dfine.me?loginGoogle=1&redirect=http://dfine.me" onclick="window.location = 'http://dfine.me?loginGoogle=1&redirect='+window.location.href; return false;"><div class="new-google-btn new-google-3 new-google-default-anim"><div class="new-google-3-1"><div class="new-google-3-1-1">Iniciar Sesión</div></div></div></a>
<a href="http://dfine.me?loginFacebook=1&redirect=http://dfine.me" onclick="window.location = 'http://dfine.me?loginFacebook=1&redirect='+window.location.href; return false;"><div class="new-fb-btn new-fb-3 new-fb-default-anim"><div class="new-fb-3-1"><div class="new-fb-3-1-1">Iniciar Sesión</div></div></div></a>
<?php else : ?>
<form action="<?php echo get_option('siteurl'); ?>/wp-comments-post.php" method="post" id="commentform">
<?php if ( is_user_logged_in() ) : ?>
<p>Sesión iniciada por <a href="<?php echo get_option('siteurl'); ?>/wp-admin/profile.php"><?php echo $user_identity; ?></a>. <br><a href="<?php echo wp_logout_url(get_permalink()); ?>" title="Cerrar sesión">Cerrar sesión »</a></p>
<?php else : //this is where we setup the comment input forums ?>
<?php endif; ?>
<!--<p><small><strong>XHTML:</strong> You can use these tags: <code><?php echo allowed_tags(); ?></code></small></p>-->
<p><textarea name="comment" id="comment" cols="90%" rows="10" tabindex="4"></textarea></p>
<p><input name="submit" type="submit" id="submit" tabindex="5" value="Post" />
<?php comment_id_fields(); ?>
</p>
<?php do_action('comment_form', $post->ID); ?>
</form>
<?php endif; // If registration required and not logged in ?>
</div>
<?php endif; // if you delete this the sky will fall on your head ?>
我更改了登录部分,因为我使用 Nextend Connect Facebook 和 Google 插件。functions.php 中的函数:
function advanced_comment($comment, $args, $depth) {
$GLOBALS['comment'] = $comment; ?>
<li <?php comment_class(); ?> id="li-comment-<?php comment_ID() ?>">
<div class="comment-author vcard">
<?php echo get_avatar($comment,$size='90',$default='<path_to_url>' ); ?>
<small class="comment-date"><?php printf(__('%1$s at %2$s'), get_comment_date(), get_comment_time()) ?></small>
<div class="comment-meta"<a href="<?php the_author_meta( 'user_url'); ?>"><?php printf(__('%s'), get_comment_author_link()) ?></a> dice:<?php edit_comment_link(__('(Edit)'),' ','') ?></div>
</div>
<div class="clear"></div>
<?php /*if ($comment->comment_approved == '0') : ?>
<em><?php _e('Your comment is awaiting moderation.') ?></em>
<br />
<?php endif; */?>
<div class="comment-text">
<?php comment_text() ?>
<div class="reply">
<?php comment_reply_link(array_merge( $args, array('depth' => $depth, 'max_depth' => $args['max_depth'], 'login_text' => "Responder"))) ?>
<?php delete_comment_link(get_comment_ID()); ?>
</div>
</div>
<div class="clear"></div>
<?php }
还有这个:
function delete_comment_link($id) {
if (current_user_can('edit_post')) {
echo '- <a href="'.admin_url("comment.php?action=cdc&c=$id").'"> Eliminar</a> ';
echo '- <a href="'.admin_url("comment.php?action=cdc&dt=spam&c=$id").'"> Spam</a>';
}
}
另外,我对核心comment-template.php 做了一些小的修改,在“回复”链接旁边添加了一张图片。评论模板.php:
if ( get_option('comment_registration') && !$user_ID )
$link = '<a rel="nofollow" class="comment-reply-login" href="' . esc_url( wp_login_url( get_permalink() ) ) . '"><img src="' . $direccion_sitio . '/images/reply.png" alt="Responder" style="margin-right:5px;">' . $login_text . '</a>';
else
$link = "<a class='comment-reply-link' href='" . esc_url( add_query_arg( 'replytocom', $comment->comment_ID ) ) . "#" . $respond_id . "' onclick='return addComment.moveForm(\"$add_below-$comment->comment_ID\", \"$comment->comment_ID\", \"$respond_id\", \"$post->ID\")'><img src='" . $direccion_sitio . "/images/reply.png' alt='Responder' style='margin-right:5px;'>$reply_text</a>";
return apply_filters('comment_reply_link', $before . $link . $after, $args, $comment, $post);
最后,CSS!
/*Comentarios*/
.comments-template{
width: 730px;
display: inline-block;
margin: 10px 0;
padding-top: 20px;
border-top: 3px dotted #CCC;
}
#comments{
padding-bottom: 10px;
border-bottom: 1px solid #EEE;
}
.commentlist{
margin: 15px 0;
}
.comment-meta{
padding: 5px 10px 1px 0;
border-bottom: 1px dashed lightGrey;
margin-bottom: 5px;
display: inline-block;
}
.comment-meta .url{
font-family: 'Franklin Gothic Book Italic', sans-serif;
font-size: 1.1em;
font-weight: 700;
}
.comment-text{
padding: 5px 0 35px 0;
min-height: 65px;
position: relative;
border-bottom: 1px solid #EEE;
margin-bottom: 10px;
}
.comment-date{
display: block;
padding-top: 5px;
font-size: 0.7em;
color: #7E7E7E;
font-style: italic;
}
.comments-template .avatar-90{
float: left;
padding: 5px 15px 10px 0;
}
.reply{
position: absolute;
bottom: 10px;
right: 10px;
}
.depth-2{
margin-left: 105px;
}
.depth-3{
margin-left: 210px;
}
#respond{
margin-bottom: 30px;
}
/*Fin Comentarios*/
如果我做对了,你的主要问题是特定评论的答案没有正确显示,所以也许你需要查看你的 CSS,在我的例子中,是 .depth 类。
如果您想测试我的自定义评论模板,您可以访问http://dfine.me并评论任何帖子中的任何内容。我在 Wordpress 首选项中的配置是只允许 1 个嵌套评论。希望这可以帮助!PS:对于混合的“英语-西班牙语”陈述感到抱歉......