如何将作者、电子邮件、Url等评论表单放入div。。
我正在使用args,但这对我不起作用
<?php
if ( post_password_required() ) {
return;
}
?>
<div id="comments" class="comments-area">
<?php // You can start editing here ?>
<?php if ( have_comments() ) : ?>
<h2 class="comments-title">
<?php
printf( // WPCS: XSS OK.
esc_html( _nx( \'One comment on “%2$s”\', \'%1$s comments on “%2$s”\', get_comments_number(), \'comments title\', \'nuvola\' ) ),
number_format_i18n( get_comments_number() ),
\'<span>\' . get_the_title() . \'</span>\'
);
?>
</h2>
<?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\', \'nuvola\' ); ?></h2>
<div class="nav-links">
<div class="nav-previous"><?php previous_comments_link( esc_html__( \'Older Comments\', \'nuvola\' ) ); ?></div>
<div class="nav-next"><?php next_comments_link( esc_html__( \'Newer Comments\', \'nuvola\' ) ); ?></div>
</div><!-- .nav-links -->
</nav><!-- #comment-nav-above -->
<?php endif; // Check for comment navigation. ?>
<ol class="commentlist">
<?php wp_list_comments(\'type=comment&callback=nuvola_comments\'); ?>
</ol>
<?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\', \'nuvola\' ); ?></h2>
<div class="nav-links">
<div class="nav-previous"><?php previous_comments_link( esc_html__( \'Older Comments\', \'nuvola\' ) ); ?></div>
<div class="nav-next"><?php next_comments_link( esc_html__( \'Newer Comments\', \'nuvola\' ) ); ?></div>
</div><!-- .nav-links -->
</nav><!-- #comment-nav-below -->
<?php endif; // Check for comment navigation. ?>
<?php endif; // Check for have_comments(). ?>
<?php
// If comments are closed and there are comments, let\'s leave a little note, shall we?
if ( ! comments_open() && \'0\' != get_comments_number() && post_type_supports( get_post_type(), \'comments\' ) ) :
?>
<p class="no-comments"><?php esc_html_e( \'Comments are closed.\', \'nuvola\' ); ?></p>
<?php endif; ?>
<?php $args = array(
-----------------------------------------------
\'author\' =>
\'<p class="comment-form-author"><label for="author">\' . __( \'Name\', \'domainreference\' ) . \'</label> \' .
( $req ? \'<span class="required">*</span>\' : \'\' ) .
\'<input id="author" name="author" type="text" value="\' . esc_attr( $commenter[\'comment_author\'] ) .
\'" size="30"\' . $aria_req . \' /></p>\',
\'email\' =>
\'<p class="comment-form-email"><label for="email">\' . __( \'Email\', \'domainreference\' ) . \'</label> \' .
( $req ? \'<span class="required">*</span>\' : \'\' ) .
\'<input id="email" name="email" type="text" value="\' . esc_attr( $commenter[\'comment_author_email\'] ) .
\'" size="30"\' . $aria_req . \' /></p>\',
\'url\' =>
\'<p class="comment-form-url"><label for="url">\' . __( \'Website\', \'domainreference\' ) . \'</label>\' .
\'<input id="url" name="url" type="text" value="\' . esc_attr( $commenter[\'comment_author_url\'] ) .
\'" size="30" /></p>\',
-----------------------------------------------
);?>
<?php comment_form( $args ); ?>
</div><!-- #comments -->
我试着
\'Author\' => \'<div>..code..\'
并在关闭div
\'url\' => \'..code.. </div>\'
但它不起作用。我所做的每一项更改,而不是预览。。我做错了?
最合适的回答,由SO网友:Greg McMullen 整理而成
这个comment_form()
在加载您的参数时不太正确。
你需要进去\'fields\' => apply_filters( \'comment_form_default_fields\', $fields ),
进入一个新的论点。附件是您需要更新的示例。
要填写的字段
$fields = array(
\'author\' =>
\'<div class="comment-form-author"><label for="author">\' . __( \'Name\', \'domainreference\' ) . \'</label> \' .
( $req ? \'<span class="required">*</span>\' : \'\' ) .
\'<input id="author" name="author" type="text" value="\' . esc_attr( $commenter[\'comment_author\'] ) .
\'" size="30"\' . $aria_req . \' /></div>\',
\'email\' =>
\'<div class="comment-form-email"><label for="email">\' . __( \'Email\', \'domainreference\' ) . \'</label> \' .
( $req ? \'<span class="required">*</span>\' : \'\' ) .
\'<input id="email" name="email" type="text" value="\' . esc_attr( $commenter[\'comment_author_email\'] ) .
\'" size="30"\' . $aria_req . \' /></div>\',
\'url\' =>
\'<div class="comment-form-url"><label for="url">\' . __( \'Website\', \'domainreference\' ) . \'</label>\' .
\'<input id="url" name="url" type="text" value="\' . esc_attr( $commenter[\'comment_author_url\'] ) .
\'" size="30" /></div>\',
);
注释表单参数
$comments_args = array(
// change the title of send button
\'label_submit\'=>\'Send\',
// change the title of the reply section
\'title_reply\'=>\'Write a Reply or Comment\',
// remove "Text or HTML to be displayed after the set of comment fields"
\'comment_notes_after\' => \'\',
// redefine your own textarea (the comment body)
\'comment_field\' => \'<div class="comment-form-comment"><label for="comment">\' . _x( \'Comment\', \'noun\' ) . \'</label><br /><textarea id="comment" name="comment" aria-required="true"></textarea></div>\',
\'fields\' => apply_filters( \'comment_form_default_fields\', $fields ),
);
comment_form($comments_args);
唯一值得注意的是
\'fields\' => apply_filters( \'comment_form_default_fields\', $fields
在
$comment_args
. 这将允许您传入更新表单字段。