How to Add Comments to Pages in WordPress

Posted on Apr 29, 2011

In some WordPress themes, the comment form will have been disabled in pages. That is often practical, as you don’t generally want your site visitors to comment on your About Page, Contact Page, Privacy Policy Page and FAQ page. However, in some cases you might wish to enable the comment form on one or more of your pages. If the option to enable a comment form in your pages is not available, here is how to add comments to pages in WordPress.

Basically, what we want to do is take a copy of the current page template, but add the code to show comments. This will mean we have two page templates, one that shows comments and one that does not.

1. You need to create a new page template, and give it a name. Open a text editor such as Notepad. Paste in to it the code you see below. Amend the text “Your Template Name” to what ever you want to call the template.

<?php
/*
Template Name: Your Template Name
*/
?>

Take a look at the example below. I changed “Your Template Name” to “Page with Comments”

How to add a new page template in WordPress - Code 1 - Helen InnesFigure 1: Click to View Larger Image

2. Now go to you the Admin Panel of your WordPress website. Click Appearance then Editor. Find the code for your regular pages; they should be in your Page.php file. (N.B. I’m using Eco Theme as my example.) Copy the code from this file.

How to add a new page template in WordPress - Code 2 - Helen InnesFigure 2: Click to View Larger Image

3. Paste this code in your text editor below the code you typed in step 1. It should look something like this:

<?php

/*

Template Name: Page with Comments

*/

?>

<?php

get_header();

include(THEME_LIB.’/_spotlight.php’);

include(THEME_LIB.’/_sub_head.php’);

include (THEME_LIB . ‘/template_page.php’);

?>

<?php

get_footer();

?>

4. Next, insert the code <?php comments_template(); ?> before the footer, so that it now looks similar to this.

How to add a new page template in WordPress - Code 3 - Helen InnesFigure 3: Click to View Larger Image

5. Save your file as a .php. (If you are not sure how to do this read my article, “How to create a sitemap for WordPress websites”. There, I discussed how you can rename a file in Notepad to use a different file extension. Though, instead of saving it as .html save it as .php.

6. Upload the file to your hosting account, into the same folder as your other php files. To do this, you will either need to use FTP, or use the ‘File Manager’ application on your hosting account.

7. Once uploaded, you will see your newly uploaded .php file in your WordPress Admin panel when you go to Appearance > Editor.

How to add a new page template in WordPress - Code 4 - Helen InnesFigure 4: Click to View Larger Image

8. Now go into the Page you want to add comments to and select your new template from the drop down list under Page Attributes.

How to add a new page template in WordPress - Code 5 - Helen Innes

Figure 5: Click to View Larger Image

I hope this helps you better understand how to add comments to pages in WordPress. If you have any questions just contact us.

No related posts.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word