WordPress: How to enable comments on *pages*

by john on September 23, 2007

I needed to turn on comments on WordPress pages (as opposed to just blog posts) for my course blog.

Here’s how to do it:

Find your theme’s page.php. Then inside “the loop” (if (have_posts(), etc.) you need to add a call to comments_popup_link. This provides the display of the number of comments (if any) and the link to the comments section or the popup, as appropriate. In my page.php, it looks like this:


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

    <div class="post" id="post-<?php the_ID(); ?>">
        <h2><?php the_title(); ?></h2>
        <div class="post-content">

          <?php comments_popup_link('No Comments »', '1 Comment »', '% Comments »'); ?>

Then go to wp-includes/comment-template.php, and find


	if ( is_single() || is_page())

Remove the check against is_page(), i.e.,


	if ( is_single() // || is_page()
              )
		return;

That is all. Once this is done, page comments go into the comments feed as usual.

{ 3 comments… read them below or add one }

carl December 11, 2007 at 9:18 pm

I’m trying to use this tip but I think the first box of code isn’t displaying fully.

It seems to go off the page.

Hang December 29, 2007 at 2:49 am

Thanks very much!! I have been searching this for long time.

john January 28, 2008 at 8:37 pm

carl – better?

Leave a Comment

Previous post: Obnoxious popup strategy of mlb.com

Next post: Rails vs. PHP