Skip to:
Content
Pages
Categories
Search
Top
Bottom

Facebook Like

  • Avatar of Svenl77
    Svenl77
    Participant

    @svenl77

    I got tired of adding the iframe that’s why I have built up a small function, which just gives you the correct Facebook Button anywhere on the site.
    Just copy this function into your functions.php and call “ where ever you want.
    If you want to use it in page and posts or text widgets as shortcode, write [facebook_like]
    `function facebook_like() {
    echo get_facebook_like();
    }
    function get_facebook_like() {

    $pageURL = ‘http’;
    if ($_SERVER["HTTPS"] == “on”) {$pageURL .= “s”;}
    $pageURL .= “://”;
    if ($_SERVER["SERVER_PORT"] != “80″) {
    $pageURL .= $_SERVER["SERVER_NAME"].”:”.$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
    } else {
    $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
    }

    $tmp = ”;
    return $tmp;
    }
    add_shortcode(‘facebook_like’, ‘get_facebook_like’);
    `

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)

You must be logged in to reply to this topic.