Adding the "Like" Button to every post
Friday, April 30, 2010 at 11:31AM I just figured out how to add the Facebook "Like" button to every post in my blog. For those of you who use squarespace, this could be pretty useful for you. You must have jquery for this to run.
<script src="http://code.jquery.com/jquery-latest.js"></script> $('.journal-entry-tag-post-body-line3').each(function(index) { $(this).append('<iframe src="http://www.facebook.com/widgets/like.php?href='+url+'" scrolling="no" frameborder="0" style="border:none; width:450px; height:80px"></iframe>'); });
<script type="text/javascript">
$(document).ready(function() {
var url = $('.title a').get(index);
});
</script>
You only need to put this once, either in the header of your entire site or in the header of your blog that you want it to live on.
----------------
Please note from Rick (rick@minervadesign.com):
I found you need to adjust the code to have the Like for each separate blog entry:
This section needs to look like this:
$('.journal-entry-tag-post-body-line3').each(function(index) {
var url = $('.journal-entry .title a').get(index);
it's working on a website for a team I run: http://www.solobreakracing.com.
If you don't, what happens is if you have other links on your website, you're actually apply the Like to that website and not the actual blog summary.






