【发布时间】:2016-12-28 11:53:23
【问题描述】:
感觉我尝试了很多东西,所以我来这里寻求帮助。对其他人有效的事情对我无效。我正在尝试嵌套 cmets,但我无法让它们工作。我的情况很奇怪,因为回复评论表单显示在您尝试回复的评论下方,但是当您点击帖子时,它不起作用。此外,如果您查看 URL,它不会从 #comment-(某个值)更改为 #respond-(某个值)。我可以看到 js 已正确加载到我的 Chrome Inspector 选项卡中。我正在正确地将评论回复排队。
我尝试过以不同的方式将脚本加入队列,将我的永久链接重置为默认值,并进行了大量代码更改,但似乎没有任何效果。任何帮助将不胜感激。我尝试过四处搜索,但找不到解决方案或遇到类似问题的人。
[编辑]:我无法在我的检查器选项卡中看到正确加载的 comment-reply.js。我尝试通过将 blahblahblah 放在 header.php 中的 wp_head 上方来强制它加载,它加载但没有效果。
这是我正在使用的代码及其所在的文件:
Single.php:
<?php
if( comments_open() ) {
comments_template();
}
?>
<?php endwhile;
endif;
?>
评论.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); ?>
函数.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的原因
-
哈哈哈你用什么? :P
-
wordpress 评论系统非常奇怪和复杂。特别是对我来说,因为我在这一切方面都非常初学者。此外,该法典并未提供有关此主题的太多信息,尤其是与其他参考文献相比时。
-
除了 wordpress 几乎没有任何东西
标签: javascript php wordpress nested comments