Add Comments To WordPress Pages

There are some WordPress themes that are coded not to show comments on pages but just individual posts. Its should be fairly easy to add comments to WordPress pages for your theme following this simple WordPress guide.

Typical WordPress themes are comprised of multiple files and usually the single.php file is used for posts and page.php for pages. To find the correct code to use login to the WordPress dashboard and open the theme editor. In version 2.7 the editor is under the Appearance module. If you see a warning on the bottom of the editor that the files are not writable then the file permissions of the themes need to be changed to be writable on the hosting account to edit them directly from the WordPress dashboard. The location of the themes files are in the themes folder within the wp-content folder in the WordPress directory, The path is: YourWordPressFiles/wp-content/themes/YourTheme

Once in the theme editor I suggest you first make a backup of the file you are going to be editing. Copy all the code of the page.php file and paste it into a text file and save it on your computer. Next look for the single.php file on the right and click it to open it in the editor. Scroll down and look for the code that calls for the comments, the exact code you need can vary but the clue is that it should have the text comments in it like this:

<?php comments_template(); ?>

What you need to do while looking at your single.php file is investigate the area above and below the comments template code to see what else may need to be included to properly display the comments on your pages. Look at a single post on your blog and see if there is anything shown above and below the comments that may need added for example you may need to copy the styling for the comments like this:

<div class=”commentsblock”>
<?php comments_template(); ?>
</div>

You may need to carefully examine the differences between the single.php file and the page.php file to determine what is needed and the exact location to place the comments code. Once you determined what code to copy and the location, copy the correct code and click the page.php file. Paste it in the same area on the page.php file and click Update File. You did make a backup right?

Now open a page on your blog to see if the comments section is showing. If there is a problem restore the page.php file with the backup file you saved on your computer and keep testing.

Because all themes are coded differently I can’t possibly cover every conceivable variation out there, for example some themes may not have a single.php or page.php file. What it really comes down to is to compare a file that has comments showing to one that isn’t and add in what is missing.

Similar Posts:



Tags: , ,

If you liked this post, feel free to leave a comment that is relevant to the post or subscribe to the feed and get future articles delivered to your feed reader.

Sorry but due to the spamming of a few all comments are moderated and will appear when approved and all drive-by comments will be deleted!

Comments

Very simple but useful :)

Reply

nice tips… anyway isn’t wordpress by default have that features?

Reply

Jeff  Replied:

Sri I doubt you even read the post, if you did you would have learned that its a theme specific setting not a general WordPress setting.

So the fact that you asked the question by just looking at the post title and then made sure to embed your link in the comment forced me to remove your links. But thanks for the visit.

Reply

Very good We need such a plugin for our Frex Blog. I guess it also works with the newest wordpress version(?)
Thanks for the tipp!

Reply

Jeff  Replied:

Forex… What plugin? Did it reference any plugins?
Is anybody actually reading the post?

Guess I need to be the link Nazi…NO LINK FOR YOU!

Reply

Nice info, I’ll try in my blog :)

Reply

Jeff,

My theme didn’t allow comments on pages, no matter whether the “Allow Comments” box was ticked or not. I looked for an hour before I finally found this post. Took me about three minutes to find the missing code and add it to page.php.

Nicely done!

Ummmm… how about this – I don’t want pingbacks on my pages, but, again, no matter whether the box is ticked or not, they show up. I’m sure there is a snippet of code (an if statement?) to add to that page.php right around the same location where I called the comment_template?

Thanks for any help you could give!

Reply

There are two ways to keep trackbacks and pingbacks off a post. There is a Discussion setting on the post editor to turn them off. This would need done on each post.

The other is to edit the comments.php file and I found good post about it here: http://www.kriesi.at/archives/wordpress-how-to-separate-comments-and-trackbacks

Reply

Jeff,

Thanks for the quick reply.

You stated “There is a Discussion setting on the post editor to turn them off. This would need done on each post.”

That’s my problem, whether I select it or deselect it, it doesn’t matter, the pingbacks are still showing up.

What I want to know is if there is a piece of code that isn’t in my theme, just like there wasn’t the call to comments_templates in my page.php of my theme.

The post you refer to seems to turn off all pings throughout the entire site. I just want to enable the existing functionality of the Discussion setting option so I can disable them on specific pages.

If there isn’t one, I’ll just keep deleting the pingbacks I get for pages I don’t want them appearing on.

Thanks!

Reply

Jeff  Replied:

I can’t say why it doesn’t work on your blog, it may be some code missing but I really don’t know.

Reply

brad hart  Replied:

While I can’t be certain as to why it works in some themes and not others in 2.7 I have my suspicious it has to do with customizing of the comments.php with plugin your plugins.

A work around I use in my new Springtime Theme until I get a better handle on why this didn’t work for it was to style my index.php the way I wanted my pages to look and then eliminate the page.php file from the theme. It works merrily and assuming you have a single.php, tag.php, author.php and category.php or at the very least the archive.php in your theme none of you other links will touch the index.php.

You can view the beta of and download Springtime at http://springtime.bloggingfornoobs.com

Reply

very nice tutorial, I geniunely didn’t know you could do that!

Reply

Thanks very much. Looks like the theme I’m using just didn’t have that code on the page sheet. I was very apprehensive about changing the code, but it worked like a charm.

Reply

I tried a test comment, but it didn’t work – 404 error.
The box to make a comment is there, but I guess it isn’t connected to anything. Please help!

Reply

Jeff  Replied:

Anastasia, sorry but the post is a “general guide”. Since all WordPress themes are coded different any issues you may experience couldn’t possibly be addressed without looking at the code of the specific theme. I draw the line there and for me to “look” at it would get into a fee based service.

Reply

[...] Comments on Wordpress Pages Tagged with: comments, trackbacks Posted by Ver on Saturday, April 25, 2009, 7:45 This news item was posted in Scripts, Wordpress category and has 0 Comments so far. I have been trying to search on how to add comments on Wordpress pages until I came across this very simple and informative post at Wordpressmax. [...]

There are two ways to keep trackbacks and pingbacks off a post. There is a Discussion setting on the post editor to turn them off. This would need done on each post…

Reply

thats it??

i discover almost all of the php file to find that bug.
but its only a missing tag..huhu..

That was google used for..

Reply

Thanks for the help, this just got me out of a jam on our website!

Reply

I followed your steps to a T and it worked like a charm!!. It made my day to find your website after searching all over WordPress trying to figure out why my Pages didn’t show comments. Thanks!

Reply

Hi, I’m trying to add a comments box to a theme that was not set to have comments in pages.

I managed to get the box on the page, but it’s too wide, and spans across the page. I want one about the size of this one. I also want the Name, Email, and URL boxes as well. Just like this one. Please help.

Thanks.

Reply

OOPs, I lied. So I see the set-up like this (with the Name and Email), but the Name, Email and URL boxes are right underneath my right sidebar, and the comments box is about 5 inches or so below that going across the whole page. How do I get it to look like this one? Is that in the Comments.php page? Thanks.

Reply

Jeff  Replied:

Since all WordPress themes are coded so differently I can’t and don’t even try to answer questions about individual themes, as stated in the fine print above.

Reply

I was able to implement your workaround and was very excited to see it work just as I had hoped. This is great!

Andrea

Reply

I was found the 404 error when I posted the comment. I just found out that it because my ISP. I test it on my friend’s home and every things just work fine.

Reply

Thank you thank you.
It was driving me crazy.
I thought I lost all my comments for a while but glad to see it’s all back.

Reply

I almost understand what you’re trying to teach here. I really appreciate the effort. After I go over it a few more time I’ll get it. I DO like how you stress backing up BEFORE you start to modify…you can always get back to where you were!!! Thanks!

Reply

Hey Jeff,

nice little tip, but I like the way how you added an emphasis on backing up the files. Many including advanced users forget this one small step of backing up that could bring a huge adverse effect.

Reply

Many thanks.

Works perfectly, also seems to work perfectly with the enabling/ disabling function built into wordpress.

Reply

Wow, you just saved me hours of searching….I love my theme but that was the one thing I couldn’t stand and your instructions were sooo easy. If you were here, I would hug you. :)

Reply

YO JEFF,

I am new to websites, but I read through your whole blog post. I put a thing about my problem on the forum about two hours ago and got no people writing me back. Anyways, let me tell you right now, I am somewhat scared to go into the pages code and make any changes, I am just hoping that my doing a copy and paste of the file onto my computer I will be able to copy and paste it back later if something gets jacked up.
I am the guy who took a C++ class for college credit back in 1997 and was freaked out that 12 year olds were light years ahead of me.

I am really thinking about having a smoke outside before doing what you are saying because I am freaking out its going to mess up my site if I do it wrong, but sounds like some people above had success, not sure what their experience level is.
I will post back my progress, but I got these comments from people that when I approve them, they dont ever show up on my sites pages, my guess is that is what your whole thing is about…If i missed the boat on your blogs point, then help me god!!!
time for a smoke break first, and thanks for making this info so easy to read

Reply

Adam  Replied:

Hey Jeff,
BA BA BOOOOOOOOOOOOOM.

YOU ARE AMAZING.

Here is the deal, I just did it thanks to you. Wife wants to kill me because I am screeaming and she is trying to fall asleep.
hey, if you are ever out in the bay area of california, email me and I am buying you dinner!!!!!!!!!!!!!!!!!!!!!!!

AMAZING, the comments are up and that is awesome, thanks so so so so so much, really appreciate it.

Want to call my C++ teacher who gave me a D and tell her to kiss my ass.

Thanks Jeff!

Reply

Leave a comment
Drive-By comments will be deleted! Like "Thanks for sharing", "Nice post", or any other text that doesn't contribute to the discussion. If you ask a very specific question about your particular WordPress theme, it will probably be deleted. I can fix your WordPress site but for a price. If you ask a question like "Why don't my blog work right", it will be deleted. If you ask a question about your WordPress site without a leaving a link to it, it will be deleted. The point is to ask questions and or comment on the the actual content of the post, and to please use some common sense. All comments are moderated and will appear when approved. Thank you.

(required)

(required)