1

Installed the official facebook plugin and seems to be working. The problem is that existing comments are still visible (with default style) above facebook comments form.

My comments.php is empty now and I see this. (Sorry about greek text, no time to change it). I emptied it because I know there is no merge possible, so moving to the fb-comments only era on this site.

Is there a way to completely remove the existing comments, or at least style them and move them after fb ones? I see no option in the backoffice of the plugin.

enter image description here

2

I don't use this plugin, but it looks like this comment template is loaded with

add_filter( 'comments_template', array( 'Facebook_Comments', 'comments_template' ) );

The simplified structure of this comment template looks like:

if ( have_comments() ) :
    // ...
    wp_list_comments( $_comment_options );
    // ...
endif; 

$_facebook_comments = Facebook_Comments::comments_box();
if ( $_facebook_comments ) {
       do_action( 'facebook_comment_form_before' );
       echo '<div id="respond">';
       echo $_facebook_comments;
       echo '</div>';
       do_action( 'facebook_comment_form_after' );
}

Then you could try to let have_comments() return false to skip the WordPress comments part.

Checking the core, we find that:

function have_comments() {
    global $wp_query;
    return $wp_query->have_comments();
 }

where the class method is defined as

function have_comments() {
    if ( $this->current_comment + 1 < $this->comment_count ) {
        return true;
    } elseif ( $this->current_comment + 1 == $this->comment_count ) {
         $this->rewind_comments();
    }

    return false;
}

You can then try

function skip_wp_comments() {   
    global $wp_query;
    $wp_query->current_comment = 999; // large number
}
add_action( 'template_redirect', 'skip_wp_comments' );

to let have_comments() return false.

If that doesn't work you could overwrite the comments_template filter to use your own template or try to play with the comment_count part.

| improve this answer | |
  • I only can upvote once.. sorry about that! Excelent answer. Thank you – Odys Jun 1 '13 at 20:08
  • thanks, I´m surprised that this isn't an option in the plugin ;-) – birgire Jun 1 '13 at 20:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.