2009-09-01 17 views
0

私は以下のフォームを作っていますが、ポストリクエストで投稿IDを送信しないため動作しません。カスタムWordpressコメントフォームを作成するにはどうしたらいいですか?

<?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> 

答えて

1

Wordpressは認識できないURLパラメータをすべて削除します。 URL文字列にカスタムパラメータを追加する1つの方法は、Add_Query_Args()関数を使用することです。

はあなたの問題を解決する必要があり Add_Query_Args Function Reference

これを見てみましょう。がんばろう。

1

ちょっとした調整だけで、動作させることができました。

<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> 

上記のコードは(私にとっては)動作します。基本的に、あなたはフォーム上にIDを紛失していました。 WPは、検証プロセスの一環として、そのIDを使用しているようです。

したがって、動作させるには、id="commentform"をフォームタグに追加してください。動作するはずです。

関連する問題