This is a complete step by step procedure for WordPress beginners on how to integrate an Oauth 2.0 compliant Facebook comments in your WordPress blog. Oauth 2.0 is the open standard for authorization and authentication adopted by Facebook beginning in 2011.
It is highly recommended to use this protocol when implementing Facebook comments in your WordPress blog.
The Complete Steps
Step1.) Go to Facebook developer page. You need to login using your standard/verified Facebook account.
Step2.) Click “Apps”.
Step3.) Click “Create New App”.
Step4.) You only need to assign a name of your apps. For example see below; it will also confirm whether it is valid or not:
Note: You do not need to enter any information on the App Namespace or click Web hosting options.
Click “Continue”. Facebook Apps would then provide you an Application ID, App Secret, etc. Make a backup of this by copying these values to blank text file and saving safely to your computer. In the succeeding steps make sure you are still logged in at Facebook. Do not yet logout.
Step5.) Measure the width of your WordPress blog post where you would like to include Facebook comments. Too much width can distort your existing template. Too little width would make it difficult for users to enter their comments.
You need to measure the width using Firebug, an add-on from Firefox.
Install Firebug then restart the browser. Go to any of your WordPress blog post. Measure the width of your existing comment area by right-clicking on it and click “Inspect element with Firebug”. And make sure you “click an element in the page to inspect”, see screenshot:
Then click “Layout” tab in your Firebug options. This is how it looks like:
The comment area is around 696 pixels in width as shown by Firebug layout. The comment area is enclosed by blue lines when selected/inspected by Firebug.
Step6.). Go to this Facebook comment configuration page.
You need to define 4 things:
a.) URL to comment on = set this to your domain homepage, e.g. http://www.php-developer.org/
b.) Number of posts = leave it at 2.
c.) Width = this is the width you have measured in step5.
d.) Color Scheme = if your website has a dark background, you need to select dark, otherwise select white.
For example, see screenshot below:
Make sure that the width is less than your comment area width. For example, since the actual width is 696 pixels, the actual Facebook width is selected at 650 pixels. You can change this at anytime.
Save the changes.
Step8.) Modify your Facebook comment code data-href parameter to work with all of your WordPress post. Change it from:
<div class="fb-comments" data-href="http://www.example.com/" data-num-posts="2" data-width="690"></div>
<div class="fb-comments" data-href="<?php the_permalink(); ?>" data-num-posts="2" data-width="690"></div>
This will allow unique comments per unique WordPress post. If you do not change this, then all comments would appear the same in all post!
Step9.) Download your existing single.php template. This is your theme single post template, used in generating your blog post content. Open it and paste the Facebook comment code just before the existing WordPress comment area (you can still have them). For example, see screenshot below (inside the red box):
You can customize further by implementing CSS styles, centering, etc.
Step10.)Upload the updated single.php and footer.php back to your WordPress server. Refresh and you would now see your Facebook comments integrated with WordPress blog posts.
Important Administration Configuration
To control spam and increase the quality of Facebook comments in your blog, the following are recommended:
Step1.) Enable moderation by downloading header.php template of your existing theme files. And then add the following code just after
<meta property="fb:app_id" content="YOUR_FACEBOOK_APP_ID">
<meta property="fb:admins" content="YOUR_FACEBOOK_USER_ID">
Replace “YOUR_FACEBOOK_USER_ID” AND “YOUR_FACEBOOK_APP_ID” with appropriate information, save and upload back to your server.
Step2.) Go to the Facebook moderation page while you are logged in to Facebook:
Step3.) Click “Settings”.
Step4.) Configure the following important items:
a.) Moderators: Add your name (the one you are using in Facebook).
b.) Select “Let me approve each comment before it appears”.
c.) Blacklisted words: “Standard Facebook restrictions”.
d.) Other login providers: Check.
e.) Grammar filter: Check.
f.) Comments composer: “Collapse when there are more than 5 comments”.
Click “Save”. This is how it looks like:
Step5.) Bookmark this URL:
You should be visiting this URL on a frequent basis to moderate new comments.