• Resolved sky_walker

    (@sky_walker)


    I’m trying to get working comments of my custom page using php scripted template (which do some math calculations).

    Somehow I managed to make it work for a moment, but by editing my script more and more I’ve crashed comments to the point where I have no idea how to fix it.
    The problem is very simple – in comments part of page I have:

    <!-- commenting_data -->
    <p><textarea name="comment" id="comment_text" tabindex="4"></textarea></p>
    
    <p><input name="submit" type="submit" id="submit" tabindex="5" value="Submit Comment" />
    <input type='hidden' name='comment_post_ID' value='' id='comment_post_ID' />
    <input type='hidden' name='comment_parent' id='comment_parent' value='0' />

    – so the value of comment_post_ID is missing.
    I have no idea how to set it up, or how it got removed – especially because I don’t use variable $comment_post_ID anywhere in my script, nor am manipulating the $_POST data.

    The php code in wp-comments-post.php throws an error in this part of code:

    if ( empty($status->comment_status) ) {
    	do_action('comment_id_not_found', $comment_post_ID);
            echo "comment_id_not_found";
            exit;
    }

    (added echo instruction to find out an error)

    Anyone might have an idea how to restore comment_post_ID? Or how to set it up again, or how to bypass the problem?

Viewing 8 replies - 1 through 8 (of 8 total)
  • the value should be <?php echo $id; ?>

    Thread Starter sky_walker

    (@sky_walker)

    it’s empty… after setting it to ID of my post I had Invalid Data: Please go back and try again. error.
    So… WP Captcha Free is spoiling the code now.
    Any ideas how to fix it without disabling the plugin?

    The list of plugins I have (might help?) :

    Collapsing Categories 0.6.3
    Evermore 2.2
    Get Recent Comments 2.0.5
    Google Analytics for WordPress 2.9.1
    List Subpages 1.0
    My Custom Widgets 1.8.1
    Robots Meta 3.0.11
    Subscribe To Comments 2.1.2
    WP-PostRatings 1.40
    WP Captcha Free 0.5

    BTW, should $id be set to page ID or not? I got confused a bit.

    Exactly the same for me. The function “comment_id_fields()” return always an empty value for the field comment_post_ID.

    Resolved. Check the call of comments_template(), it must be inside the post loop to work properly:

    while ( have_posts() ) { must be here }

    Thread Starter sky_walker

    (@sky_walker)

    Well – it wasn’t entirely true for me.
    But the idea was great ??

    Here is the code I used to put Comments into my fully customized template page:

    <div>Here is the template</div>
    
    <?php if (have_posts()) : while (have_posts()) : the_post();  comments_template();  endwhile; endif; ?>
    
    <div>and here is the stuff after the template</div>

    I recently have the same error and found this page.
    I find the problem was not the loop, you can put the comment form anywhere you like but remember to put the_post(); somewhere before your form. Usually right after if ( comments_open() ) :

    so it become

    <?php if ( comments_open() ) : the_post(); ?>
    Your form
    <?php endif; ?>
    clickit

    (@clickit)

    preaxz, you are a star my friend.
    I was experiencing the white screen of death with comments on a template page after submitting the form. You’re solution seems to work just fine.

    I am working on a similar issue and I was wondering if anyone knows how “comment_post_ID” is generated…
    I am trying to create a comment form for a content/page that was NOT created within WP… How does WP assign the value of comment_post_ID? I used to think it was the ID of the post but it isn’t, or else every comment to one post would have that number

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Missing $comment_post_ID on template page’ is closed to new replies.