Facebook comments box on front page

I have a WordPress 3.5.1 installation on my WordPress Shack, with the Facebook plugin 1.3.1 installed and the TwentyTwelve 1.1 theme. I have the settings on Facebook – Comments box so that I display the comments box on posts and pages. In Settings – Reading, I checked a static page as front page, “Welcome”. I’ve checked the “Allow comments” checkbox for every page on my site.

However, the Facebook comments box is displayed on every page, except the front page, “Welcome”.

This definitely is an issue with the front page, because if I select “latest posts” to display on the front page, the comments box is displayed on the Welcome page.

How can I make that the comments box is displayed on the front page as well?

I of course posted this at the WordPress support forums for Facebook, but I don’t get any response.

4 Answers
4

Fast ‘n’ Hacky

The problem can be solved by changing line 319 in facebook.php to the following:

if (is_home()) {

This way, the front page is not treated as a home page but as a regular page, for which the facebook feature settings can be applied (and will be handled correctly).


More Elegant/Complex

Here is a non-hackish version. Put the following in your functions.php:

add_action('template_redirect', 'force_facebook_comments');
function force_facebook_comments() {
    if (is_front_page()) {
        $features = get_option('facebook_home_features');
        $features['comments'] = true;
        update_option('facebook_home_features', $features);
        add_filter('comments_template', array('Facebook_Comments', 'comments_template'));
    }
    // If you want to handle the 'home' page differently, undo the above stuff
    // elseif (is_home()) {
        // $features = get_option('facebook_home_features');
        // $features['comments'] = false;
        // update_option('facebook_home_features', $features);
        // remove_filter('comments_template', array('Facebook_Comments', 'comments_template'));
    // }
}

Leave a Comment