WordPress

Understanding comments-popup.php

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.

16 Responses to “Understanding comments-popup.php”

  1. Nyssa

    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).

  2. Hafiz Rahman

    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.

  3. Ptah Dunbar

    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?

  4. Hafiz Rahman

    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.

  5. Nyssa

    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.

  6. Darren Hoyt

    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.

  7. Hafiz Rahman

    Nyssa,
    that is a good example! And thanks for mentioning Pixelpost… never heard about it before.

    Darren,
    thanks for the kind words :)

  8. Nickolas

    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.

  9. CT

    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.

  10. Thomas

    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

  11. Brent

    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

  12. TimeWaster

    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.

  13. » How to Make Comments Show In PopUp Window In Wordpress - MoneyGirls Blogging On The Internet »

    [...] 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 [...]

  14. Ryan

    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.

  15. TuffElillaTom

    Thanks the author!

  16. Ashish Jha

    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

Leave a Reply

Hello!

My name is Hafiz Rahman. I do standards-based web design and WordPress works. I'm open for new projects, and here's where you can contact me.

Featured Works

Whitespace Nation, a free WordPress theme.

Whitespace Nation, a free WordPress theme.

See all featured work →