I have a confession to make.
Up until now, I didn’t have any idea how comments-popup.php works. Oh, it’s not like I haven’t done any research. The Codex’s Theme Development page, for instance, explains this file as:
The popup comments template. If not present, comments-popup.php from the “default” Theme is used.
And it doesn’t link to any specific page explaining more about it. On another page, Using Themes, the information is even more sparse:
Popup Comments Template = comments-popup.php
For quite a long time, my understanding is that this file is used if, somewhere within WordPress, the option to display comments as a popup is activated. When that magic switch is on, people who click the comment link will get a popup window with the comment area inside it. The question is, where on earth do I find that option?
Oh, don’t ask me how many hours I’ve spent looking around for it. I’m even tempted to enter the famous Konami Code inside the WP admin area just to see if a secret page will open and show me the magic “Display Comment as Popup” option—it’s really that hard to find!
And no wonder. I just got the revelation today, and it turns out there’s never been such option within the admin area. Nope. I was digging in the wrong place.
The option to use comments-popup.php, ladies and gentlemen, depends solely on the presence of a single PHP line inside a theme’s header file. Go open the header.php of the Classic theme (available in any default install of WordPress), line 21 you will see:
<?php //comments_popup_script(); // off by default ?>
Yes! That’s the magic switch. The Holy Grail of Popup Commenting. I uncommented that and, bam, the very first WordPress comment popup appared before my very eyes. Try it.
By searching for that PHP function into the Codex, I found this small but complete explanation about popup comments, which I wished I’ve found before.
Anyways, it’s also interesting to note that many, many themes out there have comments-popup.php inside them but no comments_popup_script() function, making it practically useless. It’s not even available within Kubrick, WordPress’s current default theme.
I’m not sure why comments_popup_script() function is not included within the default theme (not even in commented form like the one inside the classic theme); to me and many others, Kubrick is the first theme we tear apart and learn in the process. Perhaps the usage of popup window is discouraged?
I’m not sure. But in my case, I’m very likely to leave out the comments-popup.php like I often do. I used to do it out of the fact that I don’t know what it does, and because Sandbox theme—another good theme I learn a lot from—does not have it. But now, after some thinking, I’ll just leave it out for one more reason:
I’ve never ever visit a WP-powered blog with popup comments (have you?). I’m sure that’s what most users experience as well—we’re already accustomed to the open-new-page-for-comments behavior.
Better not mess with that.
January 28th, 2008 at 2:31 am
Ahh well that makes a lot of sense. I’ve never even seen that line before.
I will continue leaving it out though. I think I’ve only ever come across one WordPress powered blog that utilized the pop-up comments, so it makes me wonder how many WordPress users actually use it (not many if I go by the amount of WordPress blogs I’ve seen).
January 28th, 2008 at 3:55 am
Hi Nyssa,
yeah I was thinking about the same thing. Since most theme does not use it (I suppose), and users are less-likely to modify a theme they use, then there shouldn’t be that many blog out there using popups.
January 28th, 2008 at 9:11 pm
why would anyone use comment-popup anyway?
I’m trying to think of a senerio where I could apply it towards that’ll make it useful.
maybe it would be better to make that functionality abstract so that you could apply that towards other functions in wp?
January 29th, 2008 at 1:16 am
Hi Ptah, I can’t think of a scenario where it’d be useful as well, which made me wonder even more why it should be there in the first place.
I think it came from the older version of WordPress and it just sort-of tag along with the updates with people barely mentioning or using it anymore.
January 29th, 2008 at 5:52 am
Ptah & Hafiz: I think a scenario it could be useful is on a photoblog powered by WordPress (which there are a few these days) so you can look at the photo while commenting (similar to how Pixelpost works on a lot it’s templates). I think that might be the only scenario though.
February 3rd, 2008 at 4:15 am
A mystery revealed – nice work. I haven’t hit a situation yet where comments should display in a pop-up, but I’m glad to know it can be done.
February 4th, 2008 at 2:47 am
Nyssa,
that is a good example! And thanks for mentioning Pixelpost… never heard about it before.
Darren,
thanks for the kind words
May 23rd, 2008 at 6:12 am
I think the pop-up comments might be a good thing to use LightBox with. I have really only seen it used with images and there’s even a plugin for it. But with some clever use it might be something interesting to use on a webpage.
Just a thought.
September 1st, 2008 at 1:52 am
This is a pretty old post, but if you’re still looking for a WP-powered site with popup-commenting, click on my linky-linked name on the left here.
As for why: I realize popups are extremely passe, but I like having them. Getting taken off the index page to a single-post page, simply to add feedback, doesn’t seem natural to me, even now that it’s the default. I like having that extra window/tab just for comment content. And of course, if anyone really wants the full page, they can always click on the Permalink tab.
I’m sure the WP geniuses will notice that PHP line one of these revisions, and figure, “nobody uses that”, and kill it off from WP once and for all. Thereby pissing me off, until I find a plugin.
September 2nd, 2008 at 7:51 am
Hafiz, thanks a lot, I was looking for a function to collaps/expand the comment area! Working on a photo portfolio blog with the theme f8 from http://www.graphpaperpress.com I will test the function to hide the comment area. Maybe it works also with the WP plugin Shadowbox JS
September 17th, 2008 at 8:51 am
I was going to mention the same thing as nicholas, you could use a modal popup window and that way not have to load another page and also not have to deal with popup blockers. Might be something to try for fun. great styling on this blog by the way!
brent
@
mimoYmima.com
September 21st, 2008 at 5:58 am
aaah, thank you very much, you saved me a lot of time searching for the holy grail.
in wordpress there are quite a lot of functions implemented whose use is not noticable instantly – i hate it.
November 2nd, 2008 at 8:19 pm
[...] was no surprise to me after reading the Understanding comments-popup.php blog article that noted that the Kubrick wordpress default theme didn’t include a [...]
November 28th, 2008 at 2:58 pm
Thank you very much
I’ve been wondering what on earth that file was for in some themes for ages. It never seemed to have any point and didn’t affect the commenting functionality of any of the themes I looked at.
December 20th, 2008 at 3:27 am
Thanks the author!
December 21st, 2008 at 8:27 am
Well. i was just checking the default theme of wp 2.7 and found this comments-popup.php page. Instead of researching myself , thought of goggling this page name. your post is useful but still i want to see the use of this comments page as i have never come across any blog which uses pop up comments. i will personally not like popup comments. if anybody knows of any blog which use this for commenting please give me the url.
thnx
May 6th, 2009 at 12:29 am
Thank you for writing this post.
I finally found the answer after keep looking in the WordPress codex for hours.
I know it’s been ages since you wrote this post, but want to thank you anyway.
–
Off the subject, I love your theme design.
^^”
May 31st, 2009 at 7:57 pm
You are a hero.
July 9th, 2009 at 9:00 am
Thanks Hafiz.
I understand now and found the good thene “Sandbox” again. (I’ve almost forgot it)
August 4th, 2009 at 5:20 am
this is something i have just been wondering about.
have searched wpress codex for ages then
decided google has always been my friend and found you.
god send….
thank you…
September 4th, 2009 at 9:32 pm
You saved my life … I was going nuts trying to figure this out. THANKS!!!
December 10th, 2009 at 12:12 am
I’ve been thinking about having a comments pop up box in wordpress – primarily because it means more clicks, which means more page views and better for the advertisers.
I’m still unsure about how to do this though? Is it possible in Wordpress or not?
Simon
December 20th, 2009 at 10:40 am
Hafiz is correct!
The first time I used WP back in 2005-2006, I had the comment box pop-up
http://imagebaker.com/v4.0/
It was inspired by these Japanese photo-blogs, which you can see they retain their basic layout from over 4 years ago!
http://million.opal.ne.jp/photoblog/
http://photomo.hassii.com/
Wow, don’t tell anyone I just had a nostalgic moment over web design.
December 20th, 2009 at 10:53 am
Oop, I’m sorry I meant in response to Nyssa:
“…I think a scenario it could be useful is on a photoblog powered by WordPress (which there are a few these days) so you can look at the photo while commenting (similar to how Pixelpost works on a lot it’s templates)…”
December 21st, 2009 at 10:04 pm
Thanks a bunch for this article dude. Much appreciated. I think the docs have gotten better. Totally decided to use popup comments out of lazyness