WordPress: How to enable comments on *pages*

23
Sep/07
3

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.

Filed under: Technology
Comments (3) Trackbacks (0)
  1. carl
    9:18 pm on December 11th, 2007

    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.

  2. Hang
    2:49 am on December 29th, 2007

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

  3. john
    8:37 pm on January 28th, 2008

    carl – better?

Leave a comment

No trackbacks yet.