2009-09-01 8 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 문자열에 사용자 정의 매개 변수를 추가하는 한 가지 방법은 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"을 추가하면 제대로 작동합니다.

관련 문제