Support » Plugins » Multiple facebook comment boxes – a facebook comment box for each WP comment

  • I am currently making a site using WordPress… and am trying to improve my comments feature.

    I am trying to include the facebook comments box plugin after EVERY comment (wordpress comment) so it appears multiple times as opposed to just once at the bottom of the page. is an example of a page I am trying to do this on.

    I have inserted the facebook comment plugin shortcode <?php echo do_shortcode(‘[fbcomments]’); ?> in various places in the comments.php in an attempt to do this but have had no luck. Does anyone know how I can do this and more importantly where, if this is the correct method, I should put this code.

    I have included the entire code from my comments.php file as shown below if that helps. Hope I’ve made what I’m trying to do clear and any help will be much appreciated. Just so you all know I’m a bit of a rookie when it comes to php so speak to me as such 🙂

    // Do not delete these lines
    if (!empty($_SERVER[‘SCRIPT_FILENAME’]) && ‘comments.php’ == basename($_SERVER[‘SCRIPT_FILENAME’]))
    die (‘Please do not load this page directly. Thanks!’);

    if ( post_password_required() ) { ?>
    <p class=”nocomments”>This post is password protected. Enter the password to view comments.</p>

    <!– You can start editing here. –>

    <?php if (have_comments()) { ?>
    <div id=”commentspost”>
    <h2 class=”title”><?php comment_type_count();?> <?php _e(‘Comments’, ‘wpzoom’); ?> </h2>
    <ol class=”normalComments”> <?php wp_list_comments(‘type=all&avatar_size=60’);?>
    </div><!– end #commentspost –>

    <?php if (‘closed’ == $post->comment_status) : ?>
    <?php endif; ?>

    <?php }
    else { // this is displayed if there are no comments so far ?>

    <?php if (‘open’ == $post->comment_status) { ?>
    <!– If comments are open, but there are no comments. –>
    <div id=”commentspost”>
    <h2 class=”title”>0 <?php _e(‘Comments’, ‘wpzoom’); ?></h2>
    <p><?php _e(‘You can be the first one to leave a confession or tell him/her what you really think. Do so anonymously below…’, ‘wpzoom’); ?>.</p>
    <?php } else { // comments are closed ?>
    <!– If comments are closed. –>
    <?php } ?>
    <?php } ?>

    <?php if (‘open’ == $post->comment_status) : ?>
    <?php echo do_shortcode(‘[fbcomments]’); ?>

    <div id=”respond”>
    <h2 class=”title”><?php comment_form_title( __(‘Leave’, ‘wpzoom’), __(‘Leave a Reply to %s’, ‘wpzoom’) ); ?></h2>
    <div class=”cleaner”> </div>
    <div class=”cancel-comment-reply”><p><?php cancel_comment_reply_link(); ?></p></div>

    <?php if ( get_option(‘comment_registration’) && !$user_ID ) : ?>
    <p><?php _e(‘You must be’, ‘wpzoom’); ?> /wp-login.php?redirect_to=<?php echo urlencode(get_permalink()); ?>”><?php _e(‘logged in’, ‘wpzoom’); ?> <?php _e(‘to post a comment.’, ‘wpzoom’); ?></p>
    <?php else : ?>

    <form action=”<?php echo get_option(‘siteurl’); ?>/wp-comments-post.php” method=”post” id=”commentform”>

    <?php if ( $user_ID ) : ?>

    <p><?php _e(‘Logged in as’, ‘wpzoom’); ?> /wp-admin/profile.php”><?php echo $user_identity; ?>. ” title=”Log out of this account”><?php _e(‘Log out’, ‘wpzoom’); ?> »</p>

    <?php else : ?>
    <div id=”formLabels”>
    <label for=”author”><?php _e(‘Name’, ‘wpzoom’); ?> <?php if ($req) echo “(required)”; ?>:</label>
    <input type=”text” name=”author” id=”author” value=”<?php echo $comment_author; ?>” size=”22″ tabindex=”1″ <?php if ($req) echo “aria-required=’true'”; ?> />

    <?php endif; ?>
    <div id=”formContent”>
    <label for=”comment”><?php _e(‘Comment’, ‘wpzoom’); ?>:</label>
    <textarea name=”comment” id=”comment” tabindex=”4″ cols=”140″ rows=”8″></textarea>
    <input name=”submit” type=”submit” id=”submit” value=”<?php _e(‘Add Comment’, ‘wpzoom’); ?>” />
    <div class=”cleaner”> </div>
    <?php comment_id_fields(); ?>
    <?php do_action(‘comment_form’, $post->ID); ?>
    <?php endif; // If registration required and not logged in ?>
    <?php endif; // if you delete this the sky will fall on your head ?

Viewing 5 replies - 1 through 5 (of 5 total)
  • Hi there,

    I really wouldn’t suggest doing this – bad for performance and user experience. However, the code above actually uses to output the comments themselves, and you need to have your own comments template to do this. More information on that is within the link above.

    Hope that helps.

    Thanks for the reply.

    How come it’s bad for performance and user experience?

    I’m not proficient enough to write out entire code from scratch 🙁

    Is there nowhere in my existing comments.php code I can insert the facebook comment box shortcode to put a facebook comment box at the bottom of each comment?


    1) Bad for user experience as multiple comment boxes for Facebook are not supposed to be output like this. All are loaded as one per URL as a whole conversation, not comment by comment. The only other solution is to make a new comment box next to every new comment with a unique URL for each. This second option means that, if 50 comments have been made, that 50 different comment boxes have to be loaded for 50 different URLs. This is the drain on performance

    2) Unfortunately this is the only method that this can be achieved

    3) Only from that link, and you will need to know the basics of PHP to implement this.

    Each comment does have its own URL but it is in the form of /texas/#comment-118 – not sure if that would work?

    The type of website it is and how I aim to generate traffic makes it pretty important that each comment has its own facebook comment box. Basically I need users to be able to direct facebook comments to each specific “anonymous” WordPress comment.

    To reduce the impact on performance I believe there is an option within the comments settings to limit a page to a certain number of comments which I will explore.

    Is changing the code from one facebook comment box per page to one per comment as simple as changing a line in the facebook plugin code or comments.php? Or does it require more?

    My php skills are limited to basic understanding of the code and copying/moving the code about.

    I appreciate you taking the time to respond to this!

    @paulo – I cannot confirm that the hashtag option as a URL as I have not tested but could work. Whatever happens, you will definitely need some work beyond comments.php to get this working how you want it to.

    If you need help please fill out the support form. Thanks

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Multiple facebook comment boxes – a facebook comment box for each WP comment’ is closed to new replies.