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()) {

$comments_args = array(
    'label_submit' => 'Submit Comment',
    'title_reply' => 'Post a Comment',
    'comment_notes_after' => ''


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.

  • What is on line 989 of events.php? That is where you should be looking, not comments.php
    – Tom J Nowell
    Commented Mar 31, 2021 at 20:28
  • 989 is just $id = $_GET[‘id’];. This is used to retrieve the database record. Commented Mar 31, 2021 at 23:15
  • Is that file in a plugin? What's the surrounding code? What does the file do?
    – Tom J Nowell
    Commented Apr 1, 2021 at 9:16
  • Yes, it is part of a plugin. I am creating an event calendar. What I believe the problem is is that because the page loads different records depending on which link is clicked. This is what the links look like. <a href="<?php echo $newlink . "?id=" . $id; ?>"><?php echo $title; ?></a> $newlink is just the link to the page, $id is the record to retrieve from the database, and $title is the title of the event. So, what needs to happen is the comments need to be associated with the correct record on that page. Commented Apr 1, 2021 at 14:20
  • Is it your plugin? It's difficult to figure out what's going on without seeing more of the code, there's not enough context to figure out how things fit together. Note though that comments are for posts, and by reusing comments for a different table you'll run into weird problems such as comments appearing on unrelated posts that share the same ID. The commenting APIs and files are not built for what you're trying to do. You will need to abandon using comments.php and the official comment form for what you're doing
    – Tom J Nowell
    Commented Apr 1, 2021 at 15:13

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

  • Though it's not what I wanted to hear, I kind of had a feeling that is what the problem would be. Thanks for the help. Commented Apr 1, 2021 at 16:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.