• Hi Everybody
    I have a page that shows list of child pages of a parent page.
    By using this code:
    <?php wp_list_comments();
    comments_template( ”, true );
    global $withcomments;
    $withcomments=1;
    comments_template();?>
    inside loop I can see the comment form for all pages (several comment form for all child pages) but when I use the first comment form and send a comment it assigns it to the last one, and it’s rational I think as it knows the id of last post (here child page), so even when I comment on first one, it shows it as a comment of the last one.
    I’d be appreciated if someone help me with right code/loop for having multi comment form when I have more than one post/page in one page.
    Thanks

Viewing 7 replies - 1 through 7 (of 7 total)
  • Moderator keesiemeijer

    (@keesiemeijer)

    If your comments.php uses the comment_form() function to display the form you can pass the post ID to it.
    https://codex.www.ads-software.com/Function_Reference/comment_form

    [untested]
    On your page template:

    global $post;
    comments_template();

    And in your comments.php:

    global $post;
    $args = array();
    comment_form( $args, $post->ID );

    Thread Starter sepehr741

    (@sepehr741)

    Hi Keesiemeijer

    Thanks a lot for your reply.
    I tried but unfortunately no luck.
    I’m using this theme:
    https://www.ads-software.com/extend/themes/redline
    Thanks for your help

    Moderator keesiemeijer

    (@keesiemeijer)

    Can you paste and submit the full code of the template file where you are using this into a pastebin.com and post the link to it here? see the Forum Rules for posting code and using the pastebin.

    Thread Starter sepehr741

    (@sepehr741)

    Hi
    Here is the link:
    https://pastebin.com/X4SgySQ5

    also at the end of the comment.php where it had :
    comment_form( $custom_args );
    I changed it as follow:

    global $post;
    $args = array();
    comment_form( $args, $post->ID );
    /* comment_form( $custom_args ); */

    Thanks again

    Moderator keesiemeijer

    (@keesiemeijer)

    Try changing it to:

    global $post;
    comment_form( $custom_args, $post->ID);

    Also not sure if this will work. I will try your theme and template.

    Thread Starter sepehr741

    (@sepehr741)

    Thanks
    It didn’t I have 2 child pages which are shown, but comment on first one is dissplayed in second one!!

    Thread Starter sepehr741

    (@sepehr741)

    I just checked and found that the form is working fine, as when I send a comment on post 1 , in dashboard I see that it’s for post 1 but the only problem is about showing the comment list as it shows them after last post at the end of page, that’s why it looks that it’s has been assigned to the last post. So I just need to modify the loop or comment.php that shows comment after each post. ?? Hopefully I can get to a point.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Using multi comment forms on multi posts page error’ is closed to new replies.