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.

Solutions Collecting From Web of "Facebook comments box on front page"

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'));
    // }

I don’t have the plugin to test this, but looking at the lines to hack, as pointed by @tf:

if ( is_home() || is_front_page() ) {
    $enabled_features = get_option( sprintf( $option_name, 'home' ) );
} else if ( is_archive() ) {
    // all archives wrapped in one option
    // is_post_type_archive || is_date || is_author || is_category || is_tag || is_tax
    $enabled_features = get_option( sprintf( $option_name, 'archive' ) );
} else {
    $post_type = get_post_type();
    if ( $post_type )
        $enabled_features = get_option( sprintf( $option_name, $post_type ) );

I think it’s possible to short-circuit the third option –} else {– using apply_filters( 'pre_option_' . $option, false );.

Something like:

foreach( array( 'post', 'page' ) as $pt )
    add_filter( "pre_option_facebook_{$pt}_features", "callback" );

function callback()
    // let the option work normally
    if( !is_front_page() )
        return false;

    return get_option( 'facebook_home_features' );

According to the Template Hierarchy front-page.php or home.php will take precedence over the other pages.

After reviewing the code for the facebook plugin the options there appears to be a different set of options for these cases.

Sounds like it could be theme related. I haven’t used Twenty Twelve much, but is the homepage generated from the Appearance > Widget section?

There are a bunch of themes that generate the homepage content based on the corresponding widget. Look in there for a box called Content Left Content Right, Homepage Content or something like that.

This has tripped me up a few times.

You stated there is no front-page.php or home.php, but if I remember correctly there should be a content-home.php that is called from the single.php or page.php.