Php 如何制作自定义Wordpress评论表单?

Php 如何制作自定义Wordpress评论表单?,php,wordpress,Php,Wordpress,我制作了以下表单,但它不工作,因为它没有在post请求中发送post id <?php require('./wp-blog-header.php'); $post = get_post($_GET['p']); ?> <form action="<?php echo get_option('siteurl'); ?>/wp-comments-post.php" method="post" > <label>Name : </label&g

我制作了以下表单,但它不工作,因为它没有在post请求中发送post id

<?php
require('./wp-blog-header.php');
$post = get_post($_GET['p']);
?>

<form action="<?php echo get_option('siteurl'); ?>/wp-comments-post.php" method="post" >
<label>Name : </label><br/>
<input name="author" id="author" type="text"/><br/>
<label>Comment : </label><br/>
<textarea name="comment" id="comment"></textarea><br/><br/>
<input name="submit"type="submit" id="submit"  value="Submit" />
<?php comment_id_fields(); ?>
<?php do_action('comment_form', $post->ID); ?>
</form>


Wordpress将删除任何它无法识别的url参数。在url字符串中添加自定义参数的一种方法是使用add\u Query\u Args()函数

看看


这应该能解决你的问题。祝你好运。

只需稍加调整就可以让它工作

<form action="<?php echo get_option('siteurl'); ?>/wp-comments-post.php" method="post" id="commentform">

<p><input type="text" name="author" id="author" value="" size="22" tabindex="1" /> 
<label for="author"><small>*</small></label></p> 

<p><input type="text" name="email" id="email" value="" size="22" tabindex="2"  /> 
<label for="email"><small>*</small></label></p> 

<p><textarea name="comment" id="comment" cols="48" rows="10" tabindex="4" onFocus="clearText(this)" onBlur="clearText(this)" ></textarea></p> 

<p><input name="submit" type="submit" id="submit" tabindex="5" value="Submit" /> 
<?php comment_id_fields(); ?>

<?php do_action('comment_form', $post->ID); ?>
</form>