Php 使用WordPress comment_form()可以';t回波内容
我试图将注释_form()作为字符串进行回显,以便可以通过ajax请求返回它 我好像想不出来 下面是一些代码:Php 使用WordPress comment_form()可以';t回波内容,php,wordpress,function,Php,Wordpress,Function,我试图将注释_form()作为字符串进行回显,以便可以通过ajax请求返回它 我好像想不出来 下面是一些代码: $response .= ' <div class="modal fade" id="commentsModal" tabindex="-1" role="dialog" aria-labelledby="commentsModalLabel"> <div class="modal-dialog" role="doc
$response .= '
<div class="modal fade" id="commentsModal" tabindex="-1" role="dialog" aria-labelledby="commentsModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
';
$commenter = wp_get_current_commenter();
$req = get_option( 'require_name_email' );
$aria_req = ( $req ? " aria-required='true'" : '' );
$fields = array(
'author' => '<p class="comment-form-author">' . '<label for="author">' . __( 'Your name' ) . '</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 address' ) . '</label> ' . ( $req ? '<span class="required">*</span>' : '' ) .
'<input id="email" name="email" type="text" value="' . esc_attr( $commenter['comment_author_email'] ) . '" size="30"' . $aria_req . ' /><br /><span>We\'ll only send you an email when someone has commented on your post.</span></p>',
);
$comments_args = array(
'fields' => $fields,
'title_reply'=>'Post a comment',
'label_submit' => 'Post comment'
);
$response .= comment_form($comments_args);
$response .= '
</div>
</div>
</div>
';
$response.='
';
$commenter=wp_get_current_commenter();
$req=get_选项('require_name_email');
$aria_req=($req?“aria required='true'”:);
$fields=数组(
“author'=>”“。”($req?“*”:“”)。
“
”,
“email'=>”。”($req?“*”:“”)。
“
只有当有人对您的帖子发表评论时,我们才会向您发送电子邮件。
”,
);
$comments\u args=数组(
“字段”=>$fields,
'title_reply'=>'Post a comment',
'label_submit'=>'Post comment'
);
$response.=comment\u表单($comments\u args);
$response.='
';
任何人都知道如何将注释表单作为字符串获取
干杯您也可以用这种方式回复
?>
<div class="modal fade" id="commentsModal" tabindex="-1" role="dialog" aria-labelledby="commentsModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<?php
$commenter = wp_get_current_commenter();
$req = get_option( 'require_name_email' );
$aria_req = ( $req ? " aria-required='true'" : '' );
$fields = array(
'author' => '<p class="comment-form-author">' . '<label for="author">' . __( 'Your name' ) . '</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 address' ) . '</label> ' . ( $req ? '<span class="required">*</span>' : '' ) .
'<input id="email" name="email" type="text" value="' . esc_attr( $commenter['comment_author_email'] ) . '" size="30"' . $aria_req . ' /><br /><span>We\'ll only send you an email when someone has commented on your post.</span></p>',
);
$comments_args = array(
'fields' => $fields,
'title_reply'=>'Post a comment',
'label_submit' => 'Post comment'
);
comment_form($comments_args, $post_id);
?>
</div>
</div>
</div>
?>
嘿@BlueSuiter我试过了,但是如果我不回$response,什么都不会返回:(哦,我看到它返回的是ajax响应,但是注释表单不在模式内。所以comment\u表单($comments\u args);
不显示也设置post\u id
类似comment\u表单($comment\u args,$post\u id)
kudoz@BlueSuiter,这正是我想要的