Page Comments

January 12th, 2009

Adding comments to your Wordpress pages is something that’s done through the theme’s PHP files. Themes actually control to a large degree what WordPress functionality you can use, because most of it needs to be made available through PHP calls. For instance, your theme may have a left sidebar but not a right one, or it may have both. If your theme is not state-of-the-art and highly customisable, you are stuck with the theme designer’s choice.

Unless you host your blog on your own domain. In that case, it is possible to modify your theme’s PHP files.

Let’s say you have a page where you want your visitors to be able to add comments. And your WordPress installation doesn’t allow for that at the moment. Here is what you do:

1. Locate the page.php file of the theme you are currently using. Download it through an FTP client to your computer (or any other place where you can edit the file). Make a backup copy of this file. Make another backup copy of this file. I warned you!

2. In page.php, add this line of code near the end of the file (specific location depends on what PHP code the theme actually uses):

<?php comments_template(); ?>

3. If you only want to add comments to a specific page (rather than all of them), add this instead:

<?php if (is_page(418)) {comments_template(); } ?>

where 418 is the pageID of the page you want to add comments to. See this post on how to obtain the pageID of a page in WordPress. To add multiple pages do this:

<?php if (is_page(2,10,15,418)) {comments_template(); } ?>

4. Finally, save and upload the page.php file back to the theme folder. And that is it! Your visitors can now add a comment to these pages.

Uncategorized | Comments | Trackback

Leave a Reply

  1.  
  2.  
  3.  
You can keep track of new comments to this post with the comments feed.

About me

My name is Marco Hokke. My blog is about the things that interest me and things I might forget if I would not blog them.

Some of my favourite things are coding, photography, beer, theater and dance, Brian Eno's ambient music, Rammstein, purple, and reading.

Archives

Blogroll

Comics

Sites

Rijksmuseum

Meta