Creating Custom Share Buttons in WordPress

cutomize wordpress share buttons

I have had the usual share buttons from various social networking sites such as Twitter and Facebook on my posts for a while. I never really thought about customizing them until a client of mine requested it. So after a while of trying different techniques, I landed on one I thought was highly convenient.

 

First, get or create your images. They can be any size and any color (just be sure people can tell whether it’s Facebook or Twitter). I am currently using share buttons within a sprite I made. This image includes icons as well and I will be using this again to write about adding those. Download

 

Now for the code:

Create a new PHP file. I called mine simply “share.php” but it can be whatever you wish. I put mine within a folder called “includes”.

 

To add your own images, you have a few options.
-First, simply make a new sprite and change the background position accordingly.
-Second, if you don’t like sprites, just replace the background image (and remove the background position).
-Last, you can just insert the image between the “a” tags.

 

To include the buttons into your theme, add this line into single.php, or page.php, or index.php, or a custom page/template file:

Here is the entire code together:

And the CSS…