Social Sharing Links Code Snippets

This topic was published by and viewed 2276 times since "". The last page revision was "".

Viewing 1 post (of 1 total)
  • Author

  • DevynCJohnson
    • Topics - 437
    • @devyncjohnson

    Numerous websites have social bookmarking and sharing links. Obviously, many web developers want to add social sharing links and bookmarking links to their web-pages. Below are code snippets for adding these links to PHP code. If static (plain HTML) code is desired, then replace the single-quotes, concatenation periods, and the PHP variables with the desired static data.

    PHP Variables

    • Page Title - $EN_TITLE=urlencode(get_the_title());
    • Page URL - $EN_URL=urlencode('http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']);
    • Site Link - $EN_SITE=urlencode('');

    Social Sharing Code

    Usage Example

    DCJTech uses the below code for its social sharing links.

    <div class="share sharing"><h6>Share</h6>
    echo '<a href="'.$EN_URL.'&amp;title='.$EN_TITLE.'" target="_blank">Delicious</a> | <a href="'.$EN_URL.'&amp;title='.$EN_TITLE.'" target="_blank">Design Float</a> | <a href="'.$EN_URL.'&amp;title='.$EN_TITLE.'" target="_blank">Digg</a> | <a href="'.$EN_URL.'" target="_blank">Facebook</a> | <a href="'.$EN_URL.'" target="_blank">Google+</a> | ';
    echo '<a href=";url='.$EN_URL.'&amp;source='.$EN_SITE.'" target="_blank">LinkedIn</a> | <a href="'.$EN_URL.'&amp;t='.$EN_TITLE.'" target="_blank">MySpace</a> | <a href=";save?u='.$EN_URL.'&amp;h='.$EN_TITLE.'" target="_blank">Newsvine</a> | <a href="'.$EN_URL.'" target="_blank">Pinterest</a> | ';
    echo '<a href="'.$EN_URL.'&amp;title='.$EN_TITLE.'" target="_blank">Reddit</a> | <a href="'.$EN_URL.'&amp;title='.$EN_TITLE.'" target="_blank">StumbleUpon</a> | <a href=";u='.$EN_URL.'&amp;t='.$EN_TITLE.'" target="_blank">Tumblr</a> | <a href="'.$EN_TITLE.'&amp;url='.$EN_URL.'&amp;via=DevynCJohnson" target="_blank">Twitter</a> | ';
    echo '<a href="javascript:window.print();" title="Print page">Print</a>';?>
Viewing 1 post (of 1 total)