Forum Moderators: coopster
<fb:like href=" [PHP SCRIPT to insert URL of the Page] " send="false" layout="button_count" width="70" show_faces="false" action="like" font="arial"><\/fb:like>
<script type="text/javascript">
//<![CDATA[
(function() {
document.write('<div id="fb-root"><\/div><fb:like href="<?php echo get_permalink( $post->ID ); ?>" send="false" layout="button_count" width="70" show_faces="false" action="like" font="arial"><\/fb:like>');
var s = document.createElement('SCRIPT'), s1 = document.getElementsByTagName('SCRIPT')[0];
s.type = 'text/javascript';
s.async = true;
s.src = 'http://connect.facebook.net/en_US/all.js#xfbml=1';
s1.parentNode.insertBefore(s, s1);
})();
//]]>
</script>
The script is within a simple .html file that has only one canonical URL (meaning there is no way it can be link in non-canonical way)
"http://www.example.com/my_folder/my_file.html".
http://www.example.com///my_folder///my_file.html http://www.example.com/my_folder/my_file.html?some-appended-stuff http://example.com/my_folder/my_file.html
The script is within a simple .html file...
<script type="text/javascript">
function getCanonicalUrl() {
var url = '';
var linkElems = document.getElementsByTagName('link');
for (var item=0; item<linkElems.length; item++) {
if (linkElems[item].rel == 'canonical') {
url = linkElems[item].href;
break;
}
}
return url;
}
</script>
...<fb:like href="' + getCanonicalUrl() + '" send="false"...