bhalash

Social sharing

Nov 22nd, 2014
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.09 KB | None | 0 0
  1. <?php $share = array(
  2.     'url'     => urlencode(get_permalink()),
  3.     'thumb'   => urlencode(get_branding_image($post->ID)),
  4.     'title'   => urlencode(get_the_title()),
  5.     'twitter' => urlencode('twitter_handle'),
  6. );
  7.  
  8. $twitter_account = 'whatever';
  9. ?>
  10.  
  11. <ul class="share">
  12.     <li class="email">
  13.         <a href="mailto:?subject=<?php echo $share['title']; ?>&amp;body=<?php echo $share['url']; ?>" data-rel="0" target="_blank" title="Share <?php echo $post->post_title; ?> via email"></a>
  14.     </li>
  15.     <li class="facebook">
  16.         <a href="//facebook.com/sharer.php?u=<?php echo $share['url']; ?>" data-rel="1" target="_blank" title="Share <?php echo $post->post_title; ?> on Facebook"></a>
  17.     </li>
  18.     <li class="google">
  19.         <a href="//plus.google.com/share?url=<?php echo $share['url']; ?>" data-rel="2" target="_blank" title="+1 <?php echo $post->post_title; ?>"></a>
  20.     </li>
  21.     <li class="twitter">
  22.         <a href="//twitter.com/share?url=<?php echo $share['url']; ?>&amp;text=Title&amp;via=<?php echo $share['twitter']; ?>" data-rel="3" target="_blank" title="Tweet about <?php echo $post->post_title; ?>"></a>
  23.     </li>
  24.     <li class="pinterest">
  25.         <a href="//pinterest.com/pin/create/button/?url=<?php echo $share['url']; ?>&amp;media=<?php echo $share['thumbnail']; ?>&amp;description=abcdefg" data-rel="4" target="_blank" title="Pin <?php echo $post->post_title; ?>"></a>
  26.     </li>
  27.     <li class="reddit">
  28.         <a href="//reddit.com/submit?url<?php echo $share['url']; ?>&amp;title=Title" data-rel="5" target="_blank" title="Upvote <?php echo $post->post_title; ?> on Reddit"></a>
  29.     </li>
  30.     <li class="tumblr">
  31.         <a href="//tumblr.com/share/link?url=<?php echo $share['url']; ?>&amp;name=Title" data-rel="6" target="_blank" title="Blog about <?php echo $post->post_title; ?>"></a>
  32.     </li>
  33.     <?php if (is_single() && comments_open()) : ?>
  34.         <li class="comments">
  35.             <a href="#comments" data-rel="7" title="Read comments on <?php echo $post->post_title; ?>"><?php echo $post->comment_count; ?></a>
  36.         </li>
  37.     <?php endif; ?>
  38. </ul>
Add Comment
Please, Sign In to add comment