How to have fb comments before wp comments

Hi, at first my fb comments were not showing but but I read a post that said to use "comment_form" in the "hooks" settings, once I did it it worked but I now wanted to know if there was any way to have the fb comments before the wp comments. Please let me know. Thanks!

  • Timothy
    • Chief Pigeon

    Hey basvan.

    To to confirm I understand correct. We are talking about the Ultimate FB plugin and not Comment plus?

    If we are talking Ultimate FB then in the admin there:

    Admin --> Network Admin --> Ultimate Facebook --> Facebook Settings.

    wp-admin/network/admin.php?page=wdfb

    Open the Comments accordion and scroll down, you will see the option to add your own hook. So it could be "comments_before_wp" as example. You then need to open your theme, fine the comments location and the following:

    <?php do_action("comments_before_wp");?>

    That creates a custom hook to place the comments where ever you please. :slight_smile:

    Hope that helps.

  • basvan
    • Design Lord, Child of Thor

    I'm confused. Where do I add this code:

    <?php do_action("comments_before_wp");?>

    When I go to editor there are several pages for the template I'm using. How do I know which one to use and also where to place it?

    Thanks!

  • Timothy
    • Chief Pigeon

    Hey basvan.

    Hard to say really, I'm not sure which theme you are using or how it is coded.

    it might be named comments.php in your theme perhaps?

    Basically which ever file it is where your comment code is located, you would place the do_action in front where you want those comments displaying.

    Hope that helps. :slight_smile:

  • basvan
    • Design Lord, Child of Thor

    Thanks Timothy,

    I found the comments.php file but there's so much code there. How do I know where to paste the code?

    I'm sorry it I'm asking for too much, I get a little nervous when I have to add code like this, so scared of messing up the entire site.

    Thanks again for all your help!

  • basvan
    • Design Lord, Child of Thor

    You mean the code in the file? If so here it is:

    <?php
    // Do not delete these lines
    if (!empty($_SERVER['SCRIPT_FILENAME']) && 'comments.php' == basename($_SERVER['SCRIPT_FILENAME']))
    	die ('Sorry, you can\'t load this page directly.');
    
    // Do we have comments OR are comments at least open
    if ( have_comments() || 'open' == $post->comment_status) : ?>
    <!-- Post Comments -->
    <div class="userComments" id="Comments">
    	<div id="comments" class="hidden"></div>
    
    	<?php
    	// Show a title "Comments" for the section
    	if ( have_comments() ) :
    		echo '<h4 class="sectionTitle">' . __('Comments', THEME_NAME) . '</h4>';
    	endif;
    
    	// Check if password protected
    	if ( post_password_required() ) {
    		echo '<p class="nocomments">';
    		_e('This post is password protected. Enter your password to view comments.',THEME_NAME );
    		echo '</p>';
    		return;
    	}
    
    	// Comment display function
    	function mytheme_comment($comment, $args, $depth) {
    		global $themePath;
    		$GLOBALS['comment'] = $comment; ?>
    
    		<li <?php comment_class(); ?> id="li-comment-<?php comment_ID() ?>">
    			<article id="comment-<?php comment_ID(); ?>">
    
    				<div class="comment-text the-comment-container item-container">
    					<div class="the-comment-content">
    
    						<?php
    						$avatar_size = AVATAR_SIZE; // defined in functions.php
    						if (!$avatar_size) $avatar_size = 35;
    
    						// Show the avatar for the current user
    						preg_match('/(?<=src=[\'|"])[^\'|"]*?(?=[\'|"])/i', get_avatar($comment, $size=$avatar_size), $avatarURL);  // filter the results for the SRC value only
    						$src = $avatarURL[0]; // set the src to the URL value
    
    						// Check if we can do a quick resize on the local image (usually a backup image for those without gravatars)
    						parse_str(htmlspecialchars_decode($avatarURL[0]), $output);
    						$imgURL = str_replace('?s='.$avatar_size, '', $output['d']); // strip query string
    						if ( $imgURL ) {
    							$image = vt_resize( '', $imgURL, $avatar_size, $avatar_size, true );
    							$src = str_replace(urlencode($imgURL), urlencode($image['url']), $avatarURL[0]);
    						}
    
    						// output the image
    						$theAvatar = '<div class="avatar" style="background-image: url(\''.$src.'\');"></div>';
    						?>
    
    						<header class="comment-header">
    							<?php echo $theAvatar; ?>
    							<div class="comment-meta commentmetadata">
    								<?php comment_reply_link(array_merge( $args, array('reply_text' => __('Reply',THEME_NAME), 'depth' => $depth, 'max_depth' => $args['max_depth']))) ?>    <?php edit_comment_link(__('Edit',THEME_NAME),' ','') ?>
    							</div>
    							<h4 class="poster-name"><cite><?php comment_author_link() ?></cite></h4>
    							<div class="comment-header-info clearfix">
    								<span class="date"><?php comment_date(); ?></span>
    							</div>
    						</header>
    
    						<div class="comment-content">
    							<?php comment_text() ?>
    						</div>
    
    						<footer class="comment-footer">
    							<?php if ($comment->comment_approved == '0') : ?>
    								<span class="awaiting_moderation"><?php _e('Your comment is awaiting moderation.', THEME_NAME) ?></span>
    							<?php endif; ?>
    						</footer>
    
    					</div>
    				</div>
    			</article>
    		<?php
    	}
    
    	function list_pings($comment, $args, $depth) {
    		$GLOBALS['comment'] = $comment; ?>
    
    		<li <?php comment_class(); ?> id="li-comment-<?php comment_ID(); ?>">
    			<cite><?php comment_author_link(); ?></cite><span class="date"><?php comment_date('m-d-y'); ?></span>
    
    		<?php
    	} 
    
    	// Comments output
    	if  ( have_comments() ) : ?>
    
    		<?php
    		if ( ! empty($comments_by_type['comment']) ) : ?>
    			<div id="CommentListWrapper">
    				<ol class="comment-list">
    					<?php
    					// show individual comments
    					wp_list_comments('callback=mytheme_comment&type=comment');
    					?>
    
    				<div class="comms-navigation">
    					<div style="float:left"><?php previous_comments_link() ?></div>
    					<div style="float:right"><?php next_comments_link() ?></div>
    				</div>
    			</div>
    			<?php
    		endif;
    
    	endif;
    
    	// Add Comment Form
    	if ('open' == $post->comment_status) : ?>
    
    		<div id="RespondToPost">
    			<a></a>
    
    			<div class="the-comment-container">
    
    				<h4 class="sectionTitle"><?php comment_form_title( __('Add a comment', THEME_NAME), __('Reply to %s', THEME_NAME) ); ?></h4>
    
    				<div class="cancel-comment-reply">
    					<?php cancel_comment_reply_link( __('Cancel reply?', THEME_NAME) ); ?>
    				</div>
    
    				<?php if ( $user_ID ) : ?>
    					<header class="comment-reply-header">
    						<?php
    						$avatar_size = AVATAR_SIZE; // defined in functions.php
    						if (!$avatar_size) $avatar_size = 35;
    
    						// Show the avatar for the current user
    						preg_match('/(?<=src=[\'|"])[^\'|"]*?(?=[\'|"])/i', get_avatar($user_ID, $size=$avatar_size), $avatarURL);  // filter the results for the SRC value only
    						echo '<div class="avatar" style="background-image: url(\''.$avatarURL[0].'\');"></div>';
    						 ?>
    						<div class="comment-meta commentmetadata">
    						</div>
    						<h4 class="poster-name comment-logged-in-link">
    							<cite><a>/wp-admin/profile.php"><?php echo $user_identity; ?></a></cite>
    						</h4>
    						<div class="comment-header-info clearfix">
    							<span class="already-logged-in"><?php _e('You are currently logged in', THEME_NAME); ?></span>  |  <a>" title="<?php _e('Log out of this account', THEME_NAME); ?>" class="comment-log-out"><?php _e('Log out', THEME_NAME); ?></a>
    						</div>
    					</header>
    				<?php endif; ?>
    
    				<?php
    				if ( get_option('comment_registration') && !$user_ID ) : ?>
    
    					<p><?php printf( __('You must be %s logged in %s to comment.', THEME_NAME), '<a href="'. get_option('siteurl') . '/wp-login.php?redirect_to='. urlencode(get_permalink()) .'">', '</a>'); ?></p>
    
    				<?php else : ?>
    					<form action="<?php echo get_option('siteurl'); ?>/wp-comments-post.php" method="post" id="PostCommentForm" class="comment-form">
    						<?php if ( !$user_ID ) : ?>
    							<p>
    								<label  class="overlabel" for="author"><?php _e('Name', THEME_NAME); ?> *</label>
    								<input type="text" class="textInput" name="author" id="author" value="<?php echo $comment_author; ?>" tabindex="1" />
    							</p>
    							<p>
    								<label class="overlabel" for="email"><?php _e('Email', THEME_NAME); ?> *</label>
    								<input type="text" class="textInput" name="email" id="email" value="<?php echo $comment_author_email; ?>" tabindex="2" />
    							</p>
    							<p>
    								<label  class="overlabel" for="url"><?php _e('Website', THEME_NAME); ?></label>
    								<input type="text" class="textInput" name="url" id="url" value="<?php echo $comment_author_url; ?>" tabindex="3" />
    							</p>
    						<?php endif; ?>
    						<p>
    							<label class="overlabel for-comment<?php if ( $user_ID ) { echo ' loggedIn'; } ?>" for="comment"><?php _e('Comment', THEME_NAME); ?></label>
    							<textarea class="textInput commentTextarea" name="comment" id="comment" cols="50" rows="12" tabindex="4"></textarea>
    						</p>
    						<div><button type="submit" class="btn"><span><?php _e('Add Comment', THEME_NAME); ?></span></button><?php comment_id_fields(); ?></div>
    						<div><?php do_action('comment_form', $post->ID); ?></div>
    					</form>
    					<?php
    				endif; // If registration required and not logged in ?>
    
    			</div>
    
    		</div><!-- END id=Respond -->
    		<?php 
    
    	endif;	// if ('open' == $post->comment_status) : ?>
    
    	<?php // trackbacks
    	if ( have_comments() ) :
    		if ( ! empty($comments_by_type['pings']) ) : ?>
    			<ol class="comment-list">
    				<?php wp_list_comments('callback=list_pings&type=pings'); ?>
    
    			<div class="comms-navigation">
    				<div style="float:left"><?php previous_comments_link() ?></div>
    				<div style="float:right"><?php next_comments_link() ?></div>
    			</div>
    			<?php
    		endif;
    	endif; ?>
    
    </div>	<!-- END Post Comments -->
    <?php endif; // if ( have_comments() || 'open' == $post->comment_status)

    Thanks so much!

  • Timothy
    • Chief Pigeon

    I suppose you could stick it around:

    if ( have_comments() || 'open' == $post->comment_status) : ?>
    <!-- Post Comments -->
    <?php do_action("comments_before_wp");?>

    Then give it a test and see.

    The conditional statement there is a check for comments and if your site has them open.

    This is above the form and comments.

    Let me know if that is the right spot :slight_smile:

    Or you could try around:

    // Comment display function

    Take care.

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.