This article just provides share link/url of Facebook, Twitter, Google Plus, Stumbleupon, Reddit, Digg and Tumblr and instruct How to add share link/url of the most popular social media websites in WordPress detail post.
1. List Of Share Link/URL
+ Facebook:
http://www.facebook.com/sharer.php?u=SHARE_URL&t=SHARE_TITLE
+ Twitter:
https://twitter.com/intent/tweet?source=SOURCE&text=SHARE_TITLE&url=SHARE_URL
+ Google Plus:
https://plus.google.com/share?url=SHARE_URL
+ Stumbleupon:
http://www.stumbleupon.com/submit?url=SHARE_URL&title=SHARE_TITLE
+ Reddit:
http://reddit.com/submit?url=SHARE_URL&title=SHARE_TITLE
+ Digg:
http://digg.com/submit?url=SHARE_URL&title=SHARE_TITLE
+ Tumblr:
http://www.tumblr.com/share/link?url=SHARE_URL&name=SHARE_TITLE&description=SHARE_CONTENT
2. Adding Share Link/URL in WordPress Detail Post
First, we need to get post detail information such as: title, link/short link and description by adding PHP code below at the top of the loop-single.php file in your WordPress template folder (after the_post())
<?php $post_title = $post->post_title; $post_link = get_permalink(); $post_shortlink = wp_get_shortlink(); $post_excerpt = $post->post_excerpt; ?> |
Note: Twitter just allow 140 characters so we just use post’s short link instead full link.
After that, add PHP script below to where you want to place the share hook.
<div class="icon-share"> <a href="http://www.facebook.com/sharer.php?u=<?php echo urlencode($post_link) ?>&t=<?php echo urlencode($post_title) ?>" target="_blank" title="Let your friends on Facebook know about this" class="fb"></a> <a href="https://twitter.com/intent/tweet?source=4rapiddev&text=<?php echo urlencode($post_title) ?>&url=<?php echo urlencode($post_shortlink) ?>" target="_blank" title="Let your followers on Twitter know about this" class="tw"></a> <a href="https://plus.google.com/share?url=<?php echo urlencode($post_link) ?>" target="_blank" title="Let your friends on Google Plus know about this" class="gg"></a> <a href="http://www.stumbleupon.com/submit?url=<?php echo urlencode($post_link) ?>&title=<?php echo urlencode($post_title) ?>&newcomment=<?php echo urlencode($post_excerpt) ?>" target="_blank" title="Let your friends on Stumbleupon know about this" class="stumblecopon"></a> <a href="http://reddit.com/submit?url=<?php echo urlencode($post_link) ?>&title=<?php echo urlencode($post_title) ?>" target="_blank" title="Let your friends on Reddit know about this" class="reddit"></a> <a href="http://digg.com/submit?url=<?php echo urlencode($post_link) ?>&title=<?php echo urlencode($post_title) ?>" rev="technology" target="_blank" title="Let your followers on Digg know about this" class="digg"></a> <a href="http://www.tumblr.com/share/link?url=<?php echo urlencode($post_link) ?>&name=<?php echo urlencode($post_title) ?>&description=<?php echo urlencode($post_excerpt) ?>" target="_blank" title="Let your friends on Tumblr know about this" class="tumblr"></a> </div> |
Note: you will need to change the style sheet and html to adapt with your current template.
And PHP code above will be render to html similar to this:
<div class="icon-share"> <a href="http://www.facebook.com/sharer.php?u=http%3A%2F%2F4rapiddev.com%2Finternet%2Fshare-link-url-of-facebook-twitter-google-plus-stumbleupon-reddit-digg-and-tumblr%2F&t=Share+Link%2F+Url+Of+Facebook%2C+Twitter%2C+Google+Plus%2C+Stumbleupon%2C+Reddit%2C+Digg+and+Tumblr" target="_blank" title="Let your friends on Facebook know about this" class="fb"></a> <a href="https://twitter.com/intent/tweet?source=4rapiddev&text=Share+Link%2F+Url+Of+Facebook%2C+Twitter%2C+Google+Plus%2C+Stumbleupon%2C+Reddit%2C+Digg+and+Tumblr&url=http%3A%2F%2F4rapiddev.com%2F%3Fp%3D4339" target="_blank" title="Let your followers on Twitter know about this" class="tw"></a> <a href="https://plus.google.com/share?url=http%3A%2F%2F4rapiddev.com%2Finternet%2Fshare-link-url-of-facebook-twitter-google-plus-stumbleupon-reddit-digg-and-tumblr%2F" target="_blank" title="Let your friends on Google Plus know about this" class="gg"></a> <a href="http://digg.com/submit?url=http%3A%2F%2F4rapiddev.com%2Finternet%2Fshare-link-url-of-facebook-twitter-google-plus-stumbleupon-reddit-digg-and-tumblr%2F&title=Share+Link%2F+Url+Of+Facebook%2C+Twitter%2C+Google+Plus%2C+Stumbleupon%2C+Reddit%2C+Digg+and+Tumblr" rev="technology" target="_blank" title="Let your followers on Digg know about this" target="_blank" title="Let your friends on Stumbleupon know about this" class="digg"></a> <a href="http://www.stumbleupon.com/submit?url=http%3A%2F%2F4rapiddev.com%2Finternet%2Fshare-link-url-of-facebook-twitter-google-plus-stumbleupon-reddit-digg-and-tumblr%2F&title=Share+Link%2F+Url+Of+Facebook%2C+Twitter%2C+Google+Plus%2C+Stumbleupon%2C+Reddit%2C+Digg+and+Tumblr&newcomment=This+article+just+provides+%3Cstrong%3Eshare+link%2Furl%3C%2Fstrong%3E+of+%3Cstrong%3EFacebook%2C+Twitter%2C+Google+Plus%2C+Stumbleupon%2C+Reddit%2C+Digg+and+Tumblr%3C%2Fstrong%3E+and+instruct+How+to+add+share+link%2Furl+of+the+most+popular+social+media+websites+in+%3Cstrong%3EWordPress+%3C%2Fstrong%3Edetail+post." title="Let your friends on Stumbleupon know about this" class="stumblecopon"></a> <a href="http://reddit.com/submit?url=http%3A%2F%2F4rapiddev.com%2Finternet%2Fshare-link-url-of-facebook-twitter-google-plus-stumbleupon-reddit-digg-and-tumblr%2F&title=Share+Link%2F+Url+Of+Facebook%2C+Twitter%2C+Google+Plus%2C+Stumbleupon%2C+Reddit%2C+Digg+and+Tumblr" target="_blank" title="Let your friends on Reddit know about this" class="reddit"></a> <a href="http://www.tumblr.com/share/link?url=http%3A%2F%2F4rapiddev.com%2Finternet%2Fshare-link-url-of-facebook-twitter-google-plus-stumbleupon-reddit-digg-and-tumblr%2F&name=Share+Link%2F+Url+Of+Facebook%2C+Twitter%2C+Google+Plus%2C+Stumbleupon%2C+Reddit%2C+Digg+and+Tumblr&description=This+article+just+provides+%3Cstrong%3Eshare+link%2Furl%3C%2Fstrong%3E+of+%3Cstrong%3EFacebook%2C+Twitter%2C+Google+Plus%2C+Stumbleupon%2C+Reddit%2C+Digg+and+Tumblr%3C%2Fstrong%3E+and+instruct+How+to+add+share+link%2Furl+of+the+most+popular+social+media+websites+in+%3Cstrong%3EWordPress+%3C%2Fstrong%3Edetail+post." target="_blank" title="Let your friends on Tumblr know about this" class="tumblr"></a> </div> |