admin管理员组文章数量:1297049
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.
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.
Share Improve this question edited Apr 1, 2021 at 14:24 Darth Mikey D asked Mar 31, 2021 at 18:24 Darth Mikey DDarth Mikey D 931 silver badge9 bronze badges 5 |1 Answer
Reset to default 1This 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
本文标签: pluginsHelp with commentsphp
版权声明:本文标题:plugins - Help with comments.php 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741640987a2389915.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
events.php
? That is where you should be looking, notcomments.php
– Tom J Nowell ♦ Commented Mar 31, 2021 at 20:28$id = $_GET[‘id’];
. This is used to retrieve the database record. – Darth Mikey D Commented Mar 31, 2021 at 23:15<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. – Darth Mikey D Commented Apr 1, 2021 at 14:20comments.php
and the official comment form for what you're doing – Tom J Nowell ♦ Commented Apr 1, 2021 at 15:13