premium WordPress photography themes

Add Social Media Buttons to Posts

There are hundreds of social media sharing plugins available in the WordPress plugin repository. But did you know that it’s super duper simple to build your own and have it integrate nicely in your own WordPress theme? Here is how:

Open up your theme’s functions.php and add this code to the bottom, right above the closing ?>

Important: Implementing code snippets can be problematic unless users have basic syntax understanding. In some cases, your functions.php file might not have a closing ?>. If this is the case, just paste the PHP function above at the bottom of the functions.php file.

If you’ve done everything right, all single posts will show Twitter and Facebook sharing icons at the end of every post.

Join over 280,000 independent website owners

The next person to join our monthly newsletter gets a 25% off coupon!

Thad is the founder of Theme.Works and Graph Paper Press. Previously, he produced online multimedia and documentary projects for USA Today including the inauguration of President Barack Obama and many others. He lives in Brooklyn, NY with his wife Abby.

Hi Thad. I’ve done as instructed. As a test i “liked” one of my posts and an image of my facebook page popped up and refused to go away. Did I copy and paste incorrectly? What would be the fix? Thanks in advance.

Hey Thad! Thanks for sharing. I kinda suspected there would be a better way, like this, to implement these buttons. But what would’ve been extra extra amazing was if you could show us how to make one like you guys have here. The expandable share with counter button. Css and those things is fairly easy to grasp but the php/js stuff is harder.

I’m wondering, would it be possible for you to show how to put a large custom facebook share button and a large twitter share button beside each other. The kind that pop open a small java window when you click on them and post to the site? I’ve included an image with the types of buttons i’m talking about.. the two at the end of the post.. ignore the others in the image.. thanks for the share!