Search code examples
positionwordpressfacebook-comments

Wordpress Plugin: Facebook comments box position


I have a problem with the "new" Facebook plugin for Wordpress. I would like to re-position it on my post page. I've read somewhere else (or maybe here) that you could use the comment box from developers.facebook.com but I want to use the original Facebook plugin. So here goes: I've found (in the plugin folder) where Facebook have put the code to install comments box in my theme. It looks like this:

public static function the_content_comments_box( $content ) {
        global $post;

        if ( ! isset( $post ) )
            return;

        $options = get_option( 'facebook_comments' );

        if ( ! is_array( $options ) || empty( $options ) )
            return $content;

        // closed posts can have comments from their previous open state
        // display noscript version of these comments
        $content .= "\n" . self::comments_markup( 'noscript' ) . "\n";

        // no option via JS SDK to display comments yet not accept new comments
        // only display JS SDK version of comments box display if we would like more comments
        if ( comments_open( $post->ID ) ) {
            $url = apply_filters( 'facebook_rel_canonical', get_permalink() );
            if ( $url ) // false could happen. let JS SDK handle compatibility mode
                $options['href'] = $url;
            $content .= self::js_sdk_markup( $options );
        }

        return $content;
    }
} 

How do put the Facebook comments box in the bottom of my post page? You can look at a random post page here: My temporary site What I'm ultimately trying to do is to have Facebook Comments box after Relaterede indlæg (related posts).

Is this at all possible?


Solution

  • I don't use the FB plugins for Wordpress because they seem bloated to me. However, here's a simple one-line code that I use to add a facebook comments box. You can place it anywhere in any template.

    <div class="fb-comments" data-href="<?php echo $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"] ?>"></div>
    

    PLEASE NOTE: this method requires that you have the Facebook SDK installed on the site. Also, it won't work as a widget unless you have enabled the ability to execute PHP in your widgets (requires a plug-in).