Comments for Pages in WordPress

Compare the single.php and page.php and add the call for the comments template to your Page template.

Just insert the following code in the page.php, before the closing </div> tag.

<!--opens comments.php-->
    <?php comments_template(); ?>

so before my page.php was like this.

<?php get_header(); ?>

    <div id="content" class="narrowcolumn">

        <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
        <div class="post" id="post-<?php the_ID(); ?>">
        <h2><?php the_title(); ?></h2>
            <div class="entry">
                <?php the_content('<p class="serif">Read the rest of this page »</p>'); ?>

                <?php wp_link_pages(array('before' => '<p><strong>Pages:</strong> ', 'after' => '</p>', 'next_or_number' => 'number')); ?>

            </div>
        </div>
        <?php endwhile; endif; ?>
    <?php edit_post_link('Edit this entry.', '<p>', '</p>'); ?>
    </div>

<?php get_sidebar(); ?>

<?php get_footer(); ?>

and once I edited it to allow comments for pages it was like this (changes highlighted in red):

<?php get_header(); ?>

    <div id="content" class="narrowcolumn">

        <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
        <div class="post" id="post-<?php the_ID(); ?>">
        <h2><?php the_title(); ?></h2>
            <div class="entry">
                <?php the_content('<p class="serif">Read the rest of this page »</p>'); ?>

                <?php wp_link_pages(array('before' => '<p><strong>Pages:</strong> ', 'after' => '</p>', 'next_or_number' => 'number')); ?>

            </div>
        </div>
        <?php endwhile; endif; ?>
    <?php edit_post_link('Edit this entry.', '<p>', '</p>'); ?>
<!–opens comments.php–>
    <?php comments_template(); ?>
    </div>

<?php get_sidebar(); ?>

<?php get_footer(); ?>

Leave a Reply