Having facebook like character encoding problem? WordPress / html

This article was written by in March 18, 2014, & may not be posted on other sites!
Original source url for this article: Having facebook like character encoding problem? WordPress / html

Having facebook like character encoding problem?
Does your facebook like or share button show strange characters in the facebook wall when visitors are liking your website? Try this:

 

Change all files to UTFf-8 without boom

Start by changing all your files to the right encoding “UTF-8 without boom”. This is best done in a simple editor like notepad++ or similar. Open your file and choose Encoding > convert to UTF-8 without boom and then save and upload your file. If you are using a wordpress childtheme then do the same with all the .php files, for example header.php, content.php, index.php, single.php and so on..

 

Add OG: elements to your html / wordpress site

OG elements are placed in your html / php file right before the closing </head> tag. Use the OG meta property elements to tell Facebook exactly which image, title or text to be displayed when a visitor clicks like / share on your website.

<meta property="fb:app_id" content="XXXXXXXXXX">
<meta property="og:title" content="Your company name">
<meta property="og:type" content="website">
<meta property="og:url" content="http://www.yoursite.com/">
<meta property="og:image" content="images/default.jpg">
<meta property="og:description" content="My site is filled with this exciting content, don't miss out!">

 

Change the language in your Facebook like / share code

When creating a facebook like or share buttom througt facebook developer tools you will get a code to paste into your website similar to this:

<div id="fb-root"></div>
<script>(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/all.js#xfbml=1&appId=XXXXXXXXXXXX";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>

Simply change the language in this code, for example to swedish, something like this:

<div id="fb-root"></div>
<script>(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/sv_SE/all.js#xfbml=1&appId=XXXXXXXXXXXX";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>

 

Facebook might cache your old data

Having the above done your Facebook like / share button might still not work. This is due to caching. Just wait and try again in an hour or two. In the meanwhile you can test your facebook application here: https://developers.facebook.com/tools/debug

Having facebook like character encoding problem? WordPress / html
Simply paste in your website url to check how your facebook like/share button will work and what will be shown on the faceboob wall.

 

Spread the word

Facebooktwittergoogle_pluslinkedinmail

Leave a Reply

Your email address will not be published. Required fields are marked *