我使用class-walker-comment.php 作为参考,我不知道为什么它不起作用。非常感谢您的帮助。
我遇到的问题是:
1) 化身不显示。
2) 此错误显示在每个注释上方:
警告:array\\u merge()[函数.数组合并]:参数#1不是数组
该错误似乎是我的函数中此位代码的结果:
comment_reply_link(array_merge
下面是我使用的完整回调函数:
function custom_comment( $comment, $depth, $args ) {
$tag = ( \'div\' === $args[\'style\'] ) ? \'div\' : \'li\'; ?>
<<?php echo $tag; ?> id="comment-<?php comment_ID(); ?>" <?php comment_class( $args[\'has_children\'] ? \'parent\' : \'\', $comment ); ?>>
<article id="div-comment-<?php comment_ID(); ?>" class="comment-inner">
<div class="comment-header">
<?php
if ( 0 != $args[\'avatar_size\'] ) { ?>
<div class="comment-avatar">
<?php echo get_avatar( $comment, $args[\'avatar_size\'] ); ?>
</div>
<?php } ?>
<div class="comment-meta-wrap">
<div class="comment-author vcard">
<!-- translators: %s: comment author link -->
<?php printf( __( \'%s <span class="says">says:</span>\' ), sprintf( \'<b class="fn">%s</b>\', get_comment_author_link( $comment ) ) ); ?>
</div><!-- .comment-author -->
<div class="comment-meta commentmetadata">
<a href="<?php echo esc_url( get_comment_link( $comment, $args ) ); ?>">
<time datetime="<?php comment_time( \'c\' ); ?>">
<!-- translators: 1: comment date, 2: comment time -->
<?php printf( __( \'%1$s at %2$s\' ), get_comment_date( \'\', $comment ), get_comment_time() ); ?>
</time>
</a>
<?php edit_comment_link( __( \'Edit\' ), \'<span class="edit-link">\', \'</span>\' ); ?>
</div><!-- .comment-meta -->
</div><!-- .comment-meta-wrap -->
</div><!-- .comment-header --> <div class="clearboth"></div>
<div class="comment-content">
<?php if ( \'0\' == $comment->comment_approved ) : ?>
<p class="comment-awaiting-moderation"><?php _e( \'Your comment is awaiting moderation.\' ); ?></p>
<?php endif; ?>
<?php comment_text(); ?>
</div><!-- .comment-content -->
<?php
comment_reply_link(
array_merge(
$args, array(
\'add_below\' => \'div-comment\',
\'depth\' => $depth,
\'max_depth\' => $args[\'max_depth\'],
\'before\' => \'<div class="reply">\',
\'after\' => \'</div>\',
)
)
); ?>
</article><!-- .comment-inner -->
下面是我的评论。php:
<?php
// You can start editing here -- including this comment!
if ( have_comments() ) :
?>
<h2 class="comments-title">
<?php
$comments_number = get_comments_number();
if ( \'1\' === $comments_number ) {
/* translators: %s: post title */
printf( _x( \'One Reply to “%s”\', \'comments title\', \'textdomain\' ), get_the_title() );
} else {
printf(
/* translators: 1: number of comments, 2: post title */
_nx(
\'%1$s Reply to “%2$s”\',
\'%1$s Replies to “%2$s”\',
$comments_number,
\'comments title\',
\'textdomain\'
),
number_format_i18n( $comments_number ),
get_the_title()
);
}
?>
</h2>
<ol class="comment-list">
<?php
wp_list_comments(
array(
\'avatar_size\' => 100,
\'style\' => \'ol\',
\'callback\' => \'custom_comment\',
\'short_ping\' => true,
)
);
?>
</ol>
<?php
the_comments_pagination(
array(
\'prev_text\' => \'<span class="screen-reader-text">\' . __( \'Previous\', \'textdomain\' ) . \'</span>\',
\'next_text\' => \'<span class="screen-reader-text">\' . __( \'Next\', \'textdomain\' ) . \'</span>\',
)
);
endif; // Check for have_comments().
// If comments are closed and there are comments, let\'s leave a little note, shall we?
if ( ! comments_open() && get_comments_number() && post_type_supports( get_post_type(), \'comments\' ) ) :
?>
<p class="no-comments"><?php _e( \'Comments are closed.\', \'textdomain\' ); ?></p>
<?php
endif;
comment_form();
?>