WordPress Fix: Allow Comments on Pages

WordPress Plugin

By default WordPress has the functionality in place for comments to be added to posts. However, out of the box there seems to be no ability to add comments to Pages created in WordPress – despite the fact that one of the settings when editing a Page is "Allow Comments".

The problem is not so much with WordPress itself as with the "Theme" or template you are using. A quick fix to one of the pages in the default theme will get you up and running.

How it is done

You will need to be able to edit the files in the default theme – either via the WordPress Admin (files must be writeable), or via FTP.

Open up the file called "page.php" which sits in the "wp-content/themes/default/" directory. Then replace it's contents with the following code and save/upload the file:

<?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="entrytext">
                <?php 
                    the_content
('<p class="serif">Read the rest of this page »</p>');
                    
link_pages('<p><strong>Pages:</strong> ''</p>''number'); 
                
?>
            </div>
        </div>
    <?php 
        
endwhile; endif;

        //Allow Admins to edit this page 
        
edit_post_link('Edit this entry.''<p>''</p>');

        //Fix to allow comments to be added to Pages
        
comments_template(); 
    
?>
    </div>
<?php 
    get_sidebar
();
    
get_footer();
?>


Of course, this example presumes you are working with the "default" theme. If you would like to fix another theme then the actual code that fixes everything is this single line:

<?php comments_template(); ?>


I hope this helps somebody – I know it would have saved me a few minutes…

Share:
  • Digg
  • Twitter
  • StumbleUpon
  • LinkedIn
  • del.icio.us
  • Reddit
  • Facebook
  • MySpace
  • Add to favorites
  • Google Bookmarks
  • Yahoo! Buzz

6 Responses to “WordPress Fix: Allow Comments on Pages”

  1. Jay Says:

    \o/
    Thank you loads

  2. Garrett Says:

    Big help! Thanks so much! This is exactly what I asked help for in the support forums (http://wordpress.org/support/topic/60602?replies=4) but didn’t get the detailed help I needed.

  3. Garrett Says:

    Question: do you know an easy way to have text wrap around a picture like you did above with the Wordpress logo? I read the docs on it under 1.5 and found it too involved to do. Thanks

  4. christina Says:

    Great help. I wanted a page for general site comments on my blog. Not much use if one can’t comment on a page. Thanks heaps.

  5. surfinmom Says:

    I came across this blog while looking for instances of the Kubrick theme in action.

    There are a couple more ‘fixes’ to the comments that can be made, while anyone’s working with the Wordpress Default (Kubrick) template. Open the comments.php file:

    1) the default date format: comment_date(‘F jS, Y’) renders May 30th, 2006

    change this to: comment_date(‘F j, Y’) and this removes the English ordinal suffix and renders the date in Associated Press format

    2) the teensy ‘e’ following the date comes from: edit_comment_link(‘e’,”,”);

    change this to something intelligent, like edit_comment_link(‘ edit’,”,”); to allow an adequate space between the date of the comment and the word ‘edit’

  6. surfinmom Says:

    P.S. There was a non-breaking space html code in the edit_comment_link fix that I posted; it got rendered by the browser as a space, as it should have been, LOL!

Leave a Reply