Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make custom share buttons

Tags:

facebook

I have always wanted to add Facebook share buttons to my applications, but the problem that I have is that they all look different. I see sites like this that have custom designed share buttons. Does anybody know a good tutorial, or have any pointers, about how to tackle this?

like image 390
Nicu Surdu Avatar asked Apr 22 '11 07:04

Nicu Surdu


People also ask

How do I create a custom Share button in WordPress?

To activate sharing buttons, navigate to Jetpack → Settings → Sharing. Here, under Sharing buttons, turn on the Add sharing buttons to your posts button. Next, from your WordPress menu, select Settings → Sharing. Under Sharing Buttons, drag the services appropriate to your website into the Enabled Services box.


1 Answers

Sharing something one facebook is quite easy, here is the HTML for my custom share button.

<div id="share_div">
    <div id="share">
        <a class="click" href="http://www.facebook.com/dialog/feed?app_id={{fbapp_id}}&link={{link_url}}&message={{share_message|urlencode}}&display=popup&redirect_uri={{link_url}}" target="_blank">
            Share
        </a>
    </div>
</div>

Where all the {{variables}} are to be replace by correct value : fbapp_id is the id of your facebook application. link_url is a link attached to the shared content (like a link to your site) and share_message|urlencode is the message that is shared and it needs to be urlencoded.

Also here some css to style this like a real facebook button :

#share {
    border:1px solid #0D386F;
    background-color:#5D7DAE;
    height:24px;
    width: 100px;
}

#share a.click {
    font-size:13px;
    font-weight:bold;
    text-align:center;
    color:#fff;
    border-top:1px solid #879DC2;
    background-color:#5D7DAE;
    padding: 2px 10px;
    cursor: pointer;
    text-decoration:none;
    width:80px;
    display:block;
}

But I let you the pleasure of customizing as you like, the important part being the href of the a tag

Does it answer your question ?

like image 134
dwarfy Avatar answered Nov 23 '22 04:11

dwarfy