我正在尝试加入我的评论。页面上的php和我的自定义注释函数不会返回任何结果(适用于帖子)。请帮我整理一下。
我希望能够创建一个ACF块来包含一个自定义注释块(但可以设置与页面上相同的样式)。
作用
function zeuligan_comment($comment, $args, $depth) {
if ( \'div\' === $args[\'style\'] ) {
$tag = \'div\';
$add_below = \'comment\';
} else {
$tag = \'li \';
$add_below = \'div-comment\';
}?>
<<?php echo $tag; comment_class( empty( $args[\'has_children\'] ) ? \'\' : \'parent\' ); ?> id="comment-<?php comment_ID() ?>"><?php
if ( \'div\' != $args[\'style\'] ) { ?>
<div id="div-comment-<?php comment_ID() ?>" class="comment-body"><?php
} ?>
<div class="comment-author vcard"><?php
if ( $args[\'avatar_size\'] != 0 ) {
echo get_avatar( $comment, $args[\'avatar_size\'] );
}; ?>
</div><?php
if ( $comment->comment_approved == \'0\' ) { ?>
<em class="comment-awaiting-moderation"><?php _e( \'Your comment is awaiting moderation.\' ); ?></em><br/><?php
} ?>
<div class="comment-content">
<?php printf( __( \'<cite class="fn">%s</cite>\' ), get_comment_author_link() ); ?>
<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>
<?php comment_text(); ?>
<div class="reply"><?php
comment_reply_link(
array_merge(
$args,
array(
\'add_below\' => $add_below,
\'depth\' => $depth,
\'max_depth\' => $args[\'max_depth\']
)
)
); ?>
</div>
</div>
<?php
if ( \'div\' != $args[\'style\'] ) : ?>
</div><?php
endif;
}
评论。php
<?php if ( post_password_required() ) { return; } ?>
<div id="comments" class="comments-area">
<?php
if ( have_comments() ) : ?>
<h2 class="comments-title">
<?php
$comments_number = get_comments_number();
if ( \'1\' === $comments_number ) {
printf( _x( \'One Reply to “%s”\', \'comments title\', \'zeuligan\' ), get_the_title() );
} else {
printf(
_nx(
\'%1$s Reply to “%2$s”\',
\'%1$s Replies to “%2$s”\',
$comments_number,
\'comments title\',
\'zeuligan\'
),
number_format_i18n( $comments_number ),
get_the_title()
);
}
?>
</h2>
<ul class="comment-list">
<?php
wp_list_comments( array(
\'avatar_size\' => 100,
\'style\' => \'ul\',
\'callback\' => \'zeuligan_comment\',
\'short_ping\' => true,
\'reply_text\' => \'Reply\',
) );
?>
</ul>
<?php the_comments_pagination( array(
\'prev_text\' => \'<span class="screen-reader-text">\' . __( \'Previous\', \'zeuligan\' ) . \'</span>\',
\'next_text\' => \'<span class="screen-reader-text">\' . __( \'Next\', \'zeuligan\' ) . \'</span>\',
) );
endif;
if ( ! comments_open() && get_comments_number() && post_type_supports( get_post_type(), \'comments\' ) ) : ?>
<p class="no-comments"><?php _e( \'Comments are closed.\', \'zeuligan\' ); ?></p>
<?php
endif;
comment_form();
?>
</div>