WordPress.org

Ready to get started?Download WordPress

Forums

raindrops
[resolved] facebook comments count (3 posts)

  1. m.stevove
    Member
    Posted 1 year ago #

    Hi,
    I replaced wordpress comments with facebook comments plug-in.
    It replaced all comments function but the comment count below the title. There is the word "Comment" left with hyperlink to post's comment.
    What I want is to replace it with this facebook comment count which counts current number of fb-comments.

    <iframe src="http://www.facebook.com/plugins/comments.php?href=<?php the_permalink(); ?>&permalink=1" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:130px; height:16px;" allowTransparency="true"></iframe>

    I found it on this site: http://wp.tutsplus.com/tutorials/add-facebook-comments-to-your-wordpress-theme/

    I would like to ask, where exactly shoul I put that iframe and what else should I do to disable the old "Comment" link.

    Thank you :)

  2. nobita
    Member
    Theme Author

    Posted 1 year ago #

    Hi m.stevove

    Do you want to change posted on commentlink from WordPress comment to facebook link?

    Please try below code.

    Paste functions.php

    <?php
    add_filter( 'raindrops_posted_on', 'my_change_comment_link' );
    
    function my_change_comment_link( $posted_on ){
    
    	$html = '<iframe
    			src="http://www.facebook.com/plugins/comments.php?href=%1$s&permalink=1" scrolling="no"
    			frameborder="0"
    			style="border:none; overflow:hidden; width:130px; height:16px;"
    			allowTransparency="true">
    			</iframe>';
    
    	$html = sprintf( $html, esc_url( get_permalink() ) );
    
        $regex = '!<a([^>]+)class="raindrops-comment-link"(.*)?>(.+)?</a>!';
    
    	return preg_replace( 	$regex,
    							$html,
    							$posted_on
    						);
    }
    ?>

    Thank you.

  3. m.stevove
    Member
    Posted 1 year ago #

    thank you! it is not ideal, but it works :)

Topic Closed

This topic has been closed to new replies.

About this Theme

About this Topic