Display Combined Comments Count Of Facebook and WordPress Comments On Blog

Our team was struggling to find out a way to display the combined comments count of Facebook and WordPress Commenting system simultaneously on our Blog site www.preetisblog.com.

In order to show comments from both the WordPress and Facebook Commenting system simultaneously, we had installed the Facebook for WordPress plugin and we had disabled comments, yeah we repeat disabled the comments from the plugin. And we had manually inserted facebook comments box in the footer of the page using a text widget, so that we could have comments from both the systems simultaneously on our page/ posts.

Now though we had the comments from both systems, but the comments count shown at various places was that from only the WordPress Comments system, for example in the bubbles showing comments count in theme twenty eleven or number of replies below the posts. Thus, it gave a very wrong impression to a new visitor to the site as regards to the number of comments. To solve this we tried to search the internet but we could not get a simple and viable solution.

Thus as we wanted to correct this, we found a very simple solution, which we are sharing here for all fellow WordPress Administrators/ Designers. Just copy and paste the code below at the end of “functions.php” file of your active theme and you will see the combined count of comments from Facebook and WordPress at all places, wherever your theme shows the comments count. We will request all fellow developers to share this post to make the life of our good friends in similar jobs easier.


/**********************************************************
*Function to display the combined comments count of facebook
*and WordPress Comments Works with Facebook for wordpress
*plugin installed. Just copy and paste this code at the
*end of the functions.php file of your active theme or into
*that of your child theme.
*Written by www.Preetisblog.com
*We may extend this to comments of other social
*plugins like google, twitter etc graduallly.
**************************************************************/
add_filter( 'get_comments_number', 'full_comment_count_preetisblog' );
// Get combined FB and WordPress comment count
function full_comment_count_preetisblog() {
global $post;
$url = get_permalink($post->ID);
global $facebook;
$cmnts = $facebook->api('?ids='.$url,'GET');
$fbcount = $cmnts[$url]['comments'];
$post_id = $post->ID;
$mypost = get_post($post_id);
if ( ! isset($mypost->comment_count) )
$wpCount = 0;
else
$wpCount = $mypost->comment_count;
$realCount = $fbcount + $wpCount;
if ($realCount == 0 || !isset($realCount)) {
$realCount = 0;
}

return $realCount;
}

Internet Connection Ok But No Content Use Public DNS

Many a times we run into a very unique problem wherein we see that though we are connected properly to our internet service provider (ISP), but we are able to access a few sites only while others may not load or return a “host not found at given address” error.

Typical symptoms of above problem will be”

1. The connection to the ISP is shown as connected on your PC.
2. If you are connected through ADSL modem, you see the DSL light glowing constantly as well as the internet LED blinking, showing internet activity OK.
3. You are able to see the web page of few sites, while others may not load at all.
4. Your internet access time is very slow for certain sites.
5. Till very recently you had a perfect internet connection and suddenly you are not able to access certain sites etc.

Above may be a result of improper DNS i.e. Domain Name Server settings in your network settings.
Generally we are provided with a DNS server setting which our PC fetches from the ISP at connection start up. God forbid if the ISP’s configured DNS server goes down, then you run into the above kind of problems.

Thats too much for the explaination of the problem, but whats the solution????

All you have to do is to set up your DNS entry to a public DNS may be one hosted by Google (at 8.8.8.8) and this is how you do it:

On Windows platform:

1. Open Network Settings in Control Panel.
2. Right Click and select properties on the network adapter, through which you connect to your ISP i.e. through which you access your internet connection. It can be the wireless adapter if you connect through wi-fi or LAN/ ethernet card if you connect through UTP cable.
3. A pop up window will show you certain properties of your network adapter. Scroll down till you see an entry “TCP/IP”. Select it and click on properties button below (which gets highlighted as you select “TCP/IP”)
4. Another pop-up window will show you the IP address and DNS settings.
5. Go down to the Domain Name Server (DNS) address. Generally it will be selected as “Obtain automatically from ISP”.
6. Change it to “Use following DNS server” and punch the following values into the address field:

8.8.8.8

7. Click on OK buttons till you reach back to the network connections window.
8. Now you may check for loading of websites in your browser, and the problem should be resolved.

Happy Surfing…..