我想知道如何在回复部分的评论表单中插入此代码。
echo get_simple_likes_button( get_comment_ID(), 1 );
我真的花了更多的时间去做但我失败了,我觉得模板非常复杂,
这是评论模板
if ( have_comments() ) : ?>
<h3 class="comments-title">
<?php
$comments_number = get_comments_number();
if ( '1' === $comments_number ) {
/* translators: %s: post title */
printf( esc_html( _x( 'One Comment on “%s”', 'comments title', 'hitmag' ) ), get_the_title() );
} else {
printf(
/* translators: 1: number of comments, 2: post title */
esc_html(
_nx(
'%1$s Comment on “%2$s”',
'%1$s Comments on “%2$s”',
$comments_number,
'comments title',
'hitmag'
)
),
number_format_i18n( $comments_number ),
get_the_title()
);
}
?>
</h3><!-- .comments-title -->
<?php if ( get_comment_pages_count() > 1 && get_option( 'page_comments' ) ) : // Are there comments to navigate through? ?>
<nav id="comment-nav-above" class="navigation comment-navigation" role="navigation">
<h2 class="screen-reader-text"><?php esc_html_e( 'Comment navigation', 'hitmag' ); ?></h2>
<div class="nav-links">
<div class="nav-previous"><?php previous_comments_link( esc_html__( 'Older Comments', 'hitmag' ) ); ?></div>
<div class="nav-next"><?php next_comments_link( esc_html__( 'Newer Comments', 'hitmag' ) ); ?></div>
</div><!-- .nav-links -->
</nav><!-- #comment-nav-above -->
<?php endif; // Check for comment navigation. ?>
<ol class="comment-list">
<?php
wp_list_comments( array(
'style' => 'ol',
'short_ping' => true,
'avatar_size' => 50,
) );
?>
</ol><!-- .comment-list -->
这是模板的第二部分,我无法弄清楚这个模板中的回复部分在哪里
<?php if ( get_comment_pages_count() > 1 && get_option( 'page_comments' ) ) : // Are there comments to navigate through? ?>
<nav id="comment-nav-below" class="navigation comment-navigation" role="navigation">
<h2 class="screen-reader-text"><?php esc_html_e( 'Comment navigation', 'hitmag' ); ?></h2>
<div class="nav-links">
<div class="nav-previous"><?php previous_comments_link( esc_html__( 'Older Comments', 'hitmag' ) ); ?></div>
<div class="nav-next"><?php next_comments_link( esc_html__( 'Newer Comments', 'hitmag' ) ); ?></div>
</div><!-- .nav-links -->
</nav><!-- #comment-nav-below -->
<?php
endif; // Check for comment navigation.
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 esc_html_e( 'Comments are closed.', 'hitmag' ); ?></p>
<?php
endif;
comment_form();
?>
答案 0 :(得分:0)
这是因为你“回应”了一个PHP函数,这是一个“不行”。删除echo
并将其放在您之前所做的位置,因为我假设您说“评论”表单,您知道它在哪里...