Share this post and let Your Dreams come true!
Every (WordPress) blogger wants to be shared by users via social buttons. But one of the most social network Twitter has limit for 140 characters including your URL. And what you need to do if your site has long domain? Anyway, your post url will have a lot of characters, so other twitter text will loose. To save Twitter characters for text you can use short URL services. One of the most one is bit.ly: free and easy to use service. Your shortener URL will looks like http://bit.ly/sOmEhAsH.
1. Bit.ly registration
Go to bitly.com
2. Get OAuth2 token
Since 2011 Bit.ly uses more secure API via OAuth2 authorize protocol. OAuth uses only their tokens for authorization. Lets get our token!
Go to Generic Access Token page.
Enter your bit.ly account password and click Generate token
Copy and remember the hash below Generic Access Token, this is your personal token for bit.ly service
Lets create a simple function in functions.php of your theme that will return a bitly shorten URL for your post URL.
This is it. Now you can use the function lenslider_bitlyshorten($post_id_or_empty) to return bitly URL.
4. Twitter WordPress code
This example is for HTML code inside WP Loop, that means global WordPress variable $post is available.
4.1 Twitter JS-init in header (<head> tag) or footer (before </body> tag)
4.2 Twitter share button code
The code is for a small twitter share button with horizontal counter:
Share this post and Be Happy!