ArtsAutosBooksBusinessEducationEntertainmentFamilyFashionFoodGamesGenderHealthHolidaysHomeHubPagesPersonal FinancePetsPoliticsReligionSportsTechnologyTravel

Embed Facebook Like & Twitter/Tweet Buttons - WordPress No Plugin

Updated on December 21, 2011
Embed Twitter and Facebook Like buttons into your WordPress blog posts. They'll help your readers share your posts with people they know.
Embed Twitter and Facebook Like buttons into your WordPress blog posts. They'll help your readers share your posts with people they know.

Want to easily embed standard Twitter and Facebook Like buttons in your WordPress blog, but want to use standard code and not necessarily a clunky plugin that could break? Believe me, I understand. After piecing together data and tutorials from several different sources, I have a method that has works nicely. You don't have to be an engineer, but messing around with a little code shouldn't totally freak you out, either.

Note: You can use this method to both display these buttons in the full blog view, or in an individual post.

1. Grab the Facebook Like Button code

Facebook makes creating and customizing a Facebook Like button pretty easy. Hop on over to their Like button page, and enter these values into the widget:

  • URL to like: CHANGETHIS (you may have to put http://CHANGETHIS to get Facebook to accept this)
  • Width: 200 (you can change this, depending on the width of your blog posts)
  • any other aesthetic options (light/dark, font, etc.)

Then click Get Code button and then select IFRAME from among the subtab options.

Paste the iframe code somewhere, like in Notepad. The code should look like this (it might be a little different since Facebook is constantly tweaking these sorts of things):

<iframe src="//;send=false&amp;layout=standard&amp;width=200&amp;show_faces=true&amp;action=like&amp;colorscheme=light&amp;font&amp;height=80&amp;appId=96285278221" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:200px; height:80px;" allowTransparency="true"></iframe>

2. Grab the Twitter Button code

This is very similar to the process for getting the embed code for the Facebook Like button. Head over to the Tweet Button page, and fill out the fields as per below:

  • 1 - Button: Horizontal count
  • 1 - Tweet text: CHANGETHIS
  • any other changes you'd like to make to the language, recommended people to follow, etc.

You can grab the code immediately below. It will look something like this:

<a href="" class="twitter-share-button" data-url="CHANGETHIS" data-text="CHANGETHIS" data-count="horizontal">Tweet</a><script type="text/javascript" src="">

3. Add some div wrappers

First, add some div wrappers to your two embed codes to create one block of code:

<div style="margin: 0 0 10px 0; float: left;">

[Twitter Tweet button embed code - from step #2]

[Facebook Like button embed code - from step #1]

<div style="clear: both;"></div>


4. Make some substitutions to CHANGETHIS

In your embed codes, you now have 3 instances of CHANGETHIS (or http://CHANGETHIS) which you must, um, change. :)

  1. TWITTER: data-url="CHANGETHIS" ----change to----- data-url="<?php echo get_permalink() ?>"
  2. TWITTER: data-text="CHANGETHIS" ----change to----- data-text="<?php the_title(); ?>"
  3. FACEBOOK:;... ----change to-----<?php echo urlencode(get_permalink($post->ID)); ?>&amp;...

5. Embed in via your Theme Editor

Drop the entire code block in between these two tags in your Single Post (single.php) and Main Index Template (index.php) files when using the Theme Editor:

<?php include 'by_author.php'; ?>


<div class="entry">

...Because every template is different, you might have to fiddle with the exact location of the code block, but that's generally where you want to put it if you want it between the blog post title and byline, and the body of the post itself.


    0 of 8192 characters used
    Post Comment

    • bookerboy profile image


      6 years ago from Ireland

      one of the most detailed hubs of all time - thanks a million !!

    • nexus25 profile image

      Mara Mei 

      6 years ago from Yogyakarta

      Try sharethis services, it's good

    • livelonger profile imageAUTHOR

      Jason Menayan 

      6 years ago from San Francisco

      Sinea: I'm not sure. I think Blogger might work differently, but if you want to try it out and let me know, I'd appreciate it!

    • Sinea Pies profile image

      Sinea Pies 

      6 years ago from Northeastern United States

      My blog is on Blogger...should the code work for that format as well?

    • profile image

      Kris Kemp 

      7 years ago

      Awesome post. You explained this very well and now I have a Facebook Like button for individual posts in my wordpress blog at

      Just what I was looking for. Thank you.

      Kris Kemp


    • profile image


      7 years ago

      Many thanks, implemented successfully.

    • profile image


      7 years ago

      Thanks for the tutorial. I've implemented this on my theme. And it works like a charm :)

    • gtmroy profile image


      7 years ago from Dhaka

      That's a very useful tutorial. I, however, use a plugin for that but I think this is very nice.

    • chamilj profile image


      7 years ago from Sri Lanka

      Very useful tutorial. Thanks!

    • Simone Smith profile image

      Simone Haruko Smith 

      7 years ago from San Francisco

      Gyah! This is SO useful! I didn't know this was so easy to do without a plugin. Love it! Thanks so much for providing the useful HTML and everything. I'm awful with this stuff, but this looks quite doable!


    This website uses cookies

    As a user in the EEA, your approval is needed on a few things. To provide a better website experience, uses cookies (and other similar technologies) and may collect, process, and share personal data. Please choose which areas of our service you consent to our doing so.

    For more information on managing or withdrawing consents and how we handle data, visit our Privacy Policy at:

    Show Details
    HubPages Device IDThis is used to identify particular browsers or devices when the access the service, and is used for security reasons.
    LoginThis is necessary to sign in to the HubPages Service.
    Google RecaptchaThis is used to prevent bots and spam. (Privacy Policy)
    AkismetThis is used to detect comment spam. (Privacy Policy)
    HubPages Google AnalyticsThis is used to provide data on traffic to our website, all personally identifyable data is anonymized. (Privacy Policy)
    HubPages Traffic PixelThis is used to collect data on traffic to articles and other pages on our site. Unless you are signed in to a HubPages account, all personally identifiable information is anonymized.
    Amazon Web ServicesThis is a cloud services platform that we used to host our service. (Privacy Policy)
    CloudflareThis is a cloud CDN service that we use to efficiently deliver files required for our service to operate such as javascript, cascading style sheets, images, and videos. (Privacy Policy)
    Google Hosted LibrariesJavascript software libraries such as jQuery are loaded at endpoints on the or domains, for performance and efficiency reasons. (Privacy Policy)
    Google Custom SearchThis is feature allows you to search the site. (Privacy Policy)
    Google MapsSome articles have Google Maps embedded in them. (Privacy Policy)
    Google ChartsThis is used to display charts and graphs on articles and the author center. (Privacy Policy)
    Google AdSense Host APIThis service allows you to sign up for or associate a Google AdSense account with HubPages, so that you can earn money from ads on your articles. No data is shared unless you engage with this feature. (Privacy Policy)
    Google YouTubeSome articles have YouTube videos embedded in them. (Privacy Policy)
    VimeoSome articles have Vimeo videos embedded in them. (Privacy Policy)
    PaypalThis is used for a registered author who enrolls in the HubPages Earnings program and requests to be paid via PayPal. No data is shared with Paypal unless you engage with this feature. (Privacy Policy)
    Facebook LoginYou can use this to streamline signing up for, or signing in to your Hubpages account. No data is shared with Facebook unless you engage with this feature. (Privacy Policy)
    MavenThis supports the Maven widget and search functionality. (Privacy Policy)
    Google AdSenseThis is an ad network. (Privacy Policy)
    Google DoubleClickGoogle provides ad serving technology and runs an ad network. (Privacy Policy)
    Index ExchangeThis is an ad network. (Privacy Policy)
    SovrnThis is an ad network. (Privacy Policy)
    Facebook AdsThis is an ad network. (Privacy Policy)
    Amazon Unified Ad MarketplaceThis is an ad network. (Privacy Policy)
    AppNexusThis is an ad network. (Privacy Policy)
    OpenxThis is an ad network. (Privacy Policy)
    Rubicon ProjectThis is an ad network. (Privacy Policy)
    TripleLiftThis is an ad network. (Privacy Policy)
    Say MediaWe partner with Say Media to deliver ad campaigns on our sites. (Privacy Policy)
    Remarketing PixelsWe may use remarketing pixels from advertising networks such as Google AdWords, Bing Ads, and Facebook in order to advertise the HubPages Service to people that have visited our sites.
    Conversion Tracking PixelsWe may use conversion tracking pixels from advertising networks such as Google AdWords, Bing Ads, and Facebook in order to identify when an advertisement has successfully resulted in the desired action, such as signing up for the HubPages Service or publishing an article on the HubPages Service.
    Author Google AnalyticsThis is used to provide traffic data and reports to the authors of articles on the HubPages Service. (Privacy Policy)
    ComscoreComScore is a media measurement and analytics company providing marketing data and analytics to enterprises, media and advertising agencies, and publishers. Non-consent will result in ComScore only processing obfuscated personal data. (Privacy Policy)
    Amazon Tracking PixelSome articles display amazon products as part of the Amazon Affiliate program, this pixel provides traffic statistics for those products (Privacy Policy)