How to add comments to Wordpress homepage

So, I use Wordpress.  I don’t like Wordpress at all, but I used it at my last job so I got some experience with it and that means that it was easier to just use it and deal with the consequences later.  I wouldn’t recommend it to another developer though, the codebase is truly hideous.

I recently wanted to add comments to my homepage.  I only like to make changes to my template and not to change any Wordpress “core code”, since then I’ll have to make all those changes everytime I update Wordpress.  I didn’t think this policy would be a problem for me this time since all I was trying to do was add the ‘comments template’ to the homepage and I thought that I should be able to just copy the appropriate line from my ’single.php’ into my ‘homepage.php’…  Wrong!   How any ‘non-technical’ person manages to use wordpress is beyond me…

Anyhow, I did some digging and found the problem.  The function comments_template in comment-template.php has these lines:

if ( ! (is_single() || is_page() || $withcomments) )
return;

I’m not going to go into the reason why these lines are harmful but I’ll just say that my argument might be summed up as “hard coded configuration”.  Anyway, these lines in homepage.php will get you what you want:

$withcomments = true;
comments_template();

Or, if you want to be a smartass like myself, this will work too:

$withcomments = “I hate wordpress”;
comments_template();

Cheers!

Tags: , , ,

3 Responses to “How to add comments to Wordpress homepage”

alvar Says:

This is just what i was looking for, thanks. But when I post a comment, it works but I get errors instead of a proper redirect.

Notice: Undefined index: _wp_unfiltered_html_comment in /Users/alvar/Sites/mh/trunk/wp/wp-comments-post.php on line 51

Warning: Cannot modify header information - headers already sent by (output started at /Users/alvar/Sites/mh/trunk/wp/wp-comments-post.php:51) in /Users/alvar/Sites/mh/trunk/wp/wp-includes/pluggable.php on line 865

Any ideas?
Thanks again.

alvar Says:

woops, happens onteh detail page as well. Something else is going on. I suspect soemthing about moving wp-content.

admin Says:

Hmmm, probably you are using a different version of Wordpress… Did you take a look at line 51 of wp-comments-post.php? I can perhaps take a look next week when I have some free time…

Leave a Reply