Articles post

  • Blank pages when commenting in Wordpress

    Tuesday, May 26th, 2009 at 4:24 pm

    I ran into this problem today and wanted to make note of what I did to resolve it:
    The problem
    When submitting a comment in Wordpress, (in my instance, it was for a page, but can be either post or page), you are taken to the page wp-comments-post.php and the page comes up blank. When I deactivated the theme and used the default, they worked fine.

    The solution
    I tried a load of things and read many posts, but this is what worked for me:

    1. Ensure that where the comment template is imported in your Wordpress theme, you have the standard “If have posts” statement.  I was using this in other parts of the page template, but hadn’t included a seperate one around the comments part. The example code is:

    ——————-

    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>

    <?php comments_template(); ?>       

    <?php endwhile; endif; ?>

    ——————-

    2. Include a hidden field below your submit button on the comment.php template. Just add it straight after the submit button code.

    ——————-

    <input type=”hidden” name=”comment_post_ID” value=”<?php echo $id; ?>” />

    ——————-

    That worked for me, there are a load of posts about this and in my case it required trying a few different things before I could get it to work.

    Hope that helps someone!

    Leave a Reply

Blog links