I have a page with a shortcode that displays information from the database. I have set it up to allow comments on the page. The problem I am having is when I click Submit Comment, I get the following message:
Notice: Undefined index: id in events.php on line 989
This line gets the id from the link the user clicks to get to this page, which works fine. Is there a way to pass this id through the comments.php page to make sure the page loads fine? Here is the comments.php code:
if (have_comments()) {
wp_list_comments('');
}
$comments_args = array(
'label_submit' => 'Submit Comment',
'title_reply' => 'Post a Comment',
'comment_notes_after' => ''
);
comment_form($comments_args);
EDIT
What the problem is is that have a page that displays different links to events on it. When I click the link, it opens the record associated with the link, which can be different each time.
So, what I need to have happen, is to have comments associated with the record displayed on that page.
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
This is not possible using the standard comment form. Comments in WordPress are built around post IDs, and are coded with this assumption down to the foundations. Even post statuses that can receive comments are hardcoded at multiple levels.
The comment form itself knows where to go afterwards via the comment_post_ID input.
You will not be able to repurpose the existing comment form to submit comments and have them handled via the normal method. You will need to rebuild the comment form from scratch, as well as the code that submits the comment, and the server-side comment submission handling.
Additionally, comments are intended for posts, and your comments on these custom table records will show up on random posts and attachments, as well as mangling comment counts and sorting
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0