Opened 14 years ago
Closed 14 years ago
#17193 closed defect (bug) (fixed)
comment_form() outputs ID fields related to get_the_id() even when passed a $post_id
Reported by: | natecook | Owned by: | ryan |
---|---|---|---|
Milestone: | 3.2 | Priority: | normal |
Severity: | normal | Version: | 3.1 |
Component: | Comments | Keywords: | |
Focuses: | Cc: |
Description
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).
Attachments (1)
Change History (4)
Note: See
TracTickets for help on using
tickets.
Patch to pass the $post_id along to get_comment_id_fields() method