感觉就像我尝试了很多东西,所以我来这里寻求帮助。为别人工作的东西并没有为我工作。我试图嵌套评论,但我无法让他们工作。我的情况很奇怪,因为回复评论表单显示在您尝试回复的评论下方,但是当您点击帖子时,它不起作用。另外,如果您查看URL,它不会从#comment-(某个值)更改为#respond-(某个值)。我可以看到js正在我的Chrome Inspector选项卡中正确加载。我正确排列评论回复。WordPress的回复评论链接
我尝试了不同的排队脚本,将我的固定链接重置为默认值,以及无数的代码更改,但似乎无法获取任何内容。任何帮助将不胜感激。我尝试过四处搜寻,但一直未能找到解决方案或有类似问题的人。
[编辑]:我看不到在我的检查器选项卡中正确加载的comment-reply.js。我尝试通过在我的header.php中将blahblahblah放置在我的wp_head之上来强制它加载,并且它已加载但没有任何效果。
这里是我使用的代码,它是在文件:
的single.php:
<?php
if(comments_open()) {
comments_template();
}
?>
<?php endwhile;
endif;
?>
的comments.php:
<?php if(have_comments()): ?>
<h4 id="comments"><?php comments_number('No Comments', 'One Comment', '% Comments'); ?></h4>
<ol class="commentlist">
<?php wp_list_comments(array(
'callback' => 'ericshio_custom_comments',
'max-depth' => 'x',
)); ?>
</ol>
<?php else : ?>
<p class="no-comments">No comments yet</p>
<?php endif; ?>
<?php
$comments_args = array(
// Change the title of send button
'label_submit' => __('Post', 'ericshio'),
// Change the title of the reply section
'title_reply' => __('Write a Reply or Comment', 'ericshio'),
);
?>
<?php comment_form($comments_args); ?>
的functions.php:
/* Custom Comments */
function ericshio_enqueue_comments_reply() {
if(get_option('thread_comments')) {
wp_enqueue_script('comment-reply');
}
}
add_action('comment_form_before', 'ericshio_enqueue_comments_reply');
function ericshio_custom_comments($comment, $args, $depth) {
$GLOBALS[' comment '] = $comment; ?>
<li <?php comment_class(); ?> id="li-comment-<?php comment_ID() ?>">
<div id="comment-<?php comment_ID(); ?>">
<div class="comment-author vcard">
<?php echo get_avatar($comment, $size='48', $default='<path_to_url>'); ?>
<?php printf (__('<cite class="fn">%s</cite> <span class="says"> says:</span>'), get_comment_author_link()) ?>
</div>
<?php if ($comment->comment_approved == '0') : ?>
<em><?php _e('Your Comment is Awaiting Moderation.') ?> </em>
<br />
<?php endif ; ?>
<div class="comment-meta commentmetadata"><a href="<?php echo htmlspecialchars(get_comment_link($comment->comment_ID)) ?>"><?php printf(__('%1$s at %2$s'), get_comment_date(), get_comment_time()) ?> </a> <?php edit_comment_link(__(' (Edit) '), ' ', ' ') ?> </div>
<div class="comment-wrapper">
<?php comment_text() ?>
<div class="reply">
<?php comment_reply_link(array_merge($args, array('depth' => $depth, 'max_depth' => $args['max_depth']))); ?>
</div>
</div>
</div>
<?php
}
这就是为什么我不碰的WordPress – Isaac
哈哈哈,你用什么?:P – ERIC
wordpress评论系统是荒谬怪异和复杂的。尤其对于我来说,因为我非常喜欢这个。此外,该法典没有提供有关此主题的更多信息,特别是与其他参考文献相比时。 – ERIC