[wp-trac] [WordPress Trac] #17193: comment_form() outputs ID fields related to get_the_id() even when passed a $post_id
WordPress Trac
wp-trac at lists.automattic.com
Wed Apr 20 17:54:30 UTC 2011
#17193: comment_form() outputs ID fields related to get_the_id() even when passed a
$post_id
--------------------------+-----------------------------
Reporter: natecook | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: General | Version: 3.1
Severity: normal | Keywords:
--------------------------+-----------------------------
Calling comment_form() and passing in a $post_id value other than the
current page's post as the second parameter results in an incorrect
comment form. The form that is returned has the hidden "comment_post_ID"
input field set to the ID of the current page, rather than the $post_id
passed into comment_form(). This issue appears if a custom template is
used to retrieve a customized group of posts (a custom content type, for
example) and then display the list of posts and the associated comment
forms.
{{{
// this code could be in a custom template used on a page with ID 101
// retrieve all my content from the "my_custom_type" content type, with
IDs 201, 202, 203
$my_posts = get_posts("post_type=my_custom_type");
foreach ($my_posts as $my_post) {
echo "<h3>Add a comment to post #{$my_post->ID}</h3>";
comment_form("", $my_post->ID);
echo "<hr />";
}
}}}
The three generated comment forms all have hidden "comment_post_ID" fields
with the same value (101), when they should have values that match the
headline written (201, 202, 203).
--
Ticket URL: <http://core.trac.wordpress.org/ticket/17193>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list