Replace Social Share WordPress Plugins with Code | Pinterest and Facebook
Tired of plugins slowing down your site or breaking with every update? You’re not alone. Using a simple code snippet to replace social share WordPress plugins gives you real control over your site’s speed, security, and design.
With just a few quick steps, you can replace heavy social plugins and skip all the extra bloat. Adding your share buttons with code means fewer chances for bugs or surprises down the road. You’ll also get cleaner pages and have a say in exactly how your buttons work and look.
Adding your snippet is easy using the free WPCode Lite plugin, or any code snippet plugin that you may already have installed on your site. Code snippet plugins are widely used to add tracking codes like the ones that Google and Pinterest use.

Why Replace Pinterest and Facebook Share Plugins with Code?
Many plugins promise quick fixes for social sharing, but often pile on extra code, slow your load times, and hijack your site’s design. Making the switch to simple code puts you in charge, cuts the clutter, and helps you build a site that is lighter and faster.
Faster Load Times and Less Bloat
When every second counts, your site speed matters. Social share plugins often add unnecessary scripts, style sheets, and tracking tools that weigh everything down.
I tested the speed of this site with a social share plugin and with the code, and my site performance was a few points higher. My social share button had dozens of platforms to share to, but I only need Pinterest and Facebook, so I’m getting exactly what I want without the bloat.
- Fewer Scripts: Direct code snippets give you just what you need. No hidden extras.
- Lightweight Performance: Less bloat leads to faster pages and a smoother browsing experience.
- Reduced Conflicts: Custom code plays nicely with your theme and other plugins because it’s minimal and direct.
Total Control Over Appearance and Placement
Want your share buttons to match your brand? Plugins limit your creative freedom, often forcing you into generic layouts or styles.
- Custom Styling: Tweak colors, sizes, or icons so your site stays on-brand.
- Precise Placement: Insert share buttons exactly where you want them—no more awkward floating bars or mismatched corners.
- Consistent Design: Avoid the cookie-cutter look that often comes with third-party buttons.
Fewer Updates and Maintenance Headaches
Keeping plugins up to date is a constant chore. Each one adds another point of risk for bugs, compatibility problems, or even malware.
- Simpler Maintenance: Code snippets don’t require updates or ongoing attention.
- Better Security: Plugins, especially free ones, can get abandoned or compromised. Code is simple and within your control.
- Lower Risk of Breakage: With fewer moving parts, you’re less likely to run into surprise errors after a WordPress update.
No Surprise Trackers or Privacy Problems
Many social sharing plugins sneak tracking scripts onto your site, often without clear consent.
- Respect User Privacy: Add only the code you trust, and skip shady scripts or third-party trackers.
- GDPR-Friendly: Stay in control of what gets loaded and shared.
Clean Code for Better SEO
Excess code doesn’t just slow down your site—it can mess with SEO and lower your Google rankings.
- Search Engines Prefer Clean Pages: The less junk code you have, the easier it is for search bots to crawl and index your content.
- Better for Core Web Vitals: Fewer external scripts help you hit good Google performance scores.
With all these benefits, swapping out plugins for quick code is a simple upgrade that can help you get more from your WordPress site—no advanced skills required.
How to install the Social Share Code
Start by checking to see if you already have a code snippets plugin. It will use words like Snippets, Headers and Footers, or Code in it. If you have a plugin already, then scroll down to grab the code and add it as an html snippet. If you don’t have a plugin already, then install WP Code Lite.
Photo by EVG Kowalievska
Installing and Setting Up WPCode Lite
Adding WPCode Lite is as easy as installing any other WordPress plugin. You don’t need to be a developer or touch your theme files—WPCode Lite does the heavy lifting.
Here's your quick install checklist:
- In your WordPress dashboard, go to Plugins → Add New.
- Search for “WPCode Lite”.
- Click Install Now, then Activate once it’s ready.
Once active, you’ll see a new option called Code Snippets in your dashboard. This is where you'll add your social share code.
Adding and Configuring the Pinterest and Facebook Share Code
After installing WPCode Lite, you’re ready to drop in your Pinterest share code.
- Go to Code Snippets → Add New in your WordPress dashboard.
- Choose Custom HTML Snippet.
- Give your snippet a clear name like “Pinterest Share Button” so you can find it later.
To control where the button appears, scroll to the Insertion section. WPCode Lite lets you display the snippet:
- Across your whole site.
- On posts, pages, or specific categories.
- Even after or before post content.
<!-- Facebook SDK -->
<div id="fb-root"></div>
<script async defer crossorigin="anonymous"
src="https://connect.facebook.net/en_US/sdk.js#xfbml=1&version=v18.0">
</script>
<!-- Floating Buttons Container -->
<div id="floating-share-buttons">
<!-- Facebook Share Button -->
<div class="fb-share-button"
data-href=""
data-layout="button"
data-size="small">
<a target="_blank"
href=""
class="fb-xfbml-parse-ignore">
Share
</a>
</div>
<!-- Pinterest Button -->
<a id="pin-it-button"
data-pin-do="buttonBookmark"
href="https://www.pinterest.com/pin/create/button/">
</a>
</div>
<!-- Pinterest Script -->
<script async defer src="https://assets.pinterest.com/js/pinit.js"></script>
<!-- Style + Script -->
<style>
#floating-share-buttons {
position: fixed;
bottom: 30px;
left: 80px;
z-index: 9999;
display: flex;
flex-direction: column;
gap: 10px;
background: white;
padding: 8px;
border-radius: 8px;
box-shadow: 0 0 10px rgba(0,0,0,0.15);
}
</style>
<script>
document.addEventListener("DOMContentLoaded", function () {
const currentUrl = window.location.href;
// Facebook dynamic update
const fbShareDiv = document.querySelector('.fb-share-button');
const fbShareLink = fbShareDiv.querySelector('a');
fbShareDiv.setAttribute('data-href', currentUrl);
fbShareLink.href = `https://www.facebook.com/sharer/sharer.php?u=${encodeURIComponent(currentUrl)}`;
if (window.FB && FB.XFBML) {
FB.XFBML.parse();
}
// Pinterest button setup
const pinBtn = document.getElementById("pin-it-button");
pinBtn.href = `https://www.pinterest.com/pin/create/button/?url=${encodeURIComponent(currentUrl)}`;
});
</script>
In this code, I positioned the buttons on the left side of my blog as floating buttons. Look at the bottom left hand side of this page to see them. If you want to change the position, experiment with the settings in this screenshot:

Turn on the snippet and hit Save. Visit a post to check that the button displays as you expect.
Adding code for your Pinterest and Facebook share buttons through WPCode Lite keeps your site fast, private, and looking just how you want. This simple switch takes just a few minutes but makes a lasting difference to your site’s design and performance.
Changing Button Placement for Better Engagement
Placement matters. If your share buttons are buried at the bottom of your content or tucked away in a sidebar, users might miss them. With code, you decide where they go—no more “one size fits all” plugin layouts.
Consider these proven spots for boosted engagement:
- Below your title: Adding share buttons near the top encourages sharing early.
- After the post content: Readers who finish your article are more likely to share.
- Floating on the side: A sticky sidebar keeps your buttons visible as someone scrolls.
- Within content: Drop a button before a key quote, chart, or popular image.
To change placement within WPCode Lite:
- Open your snippet and look for the Insertion settings.
- Choose “Insert After Post” to target engaged readers.
- Try “Manual Placement” and use the provided shortcode to drop the button anywhere you want within your template or post.
The key is to test. Every audience is different. Watch where users seem to respond best, and tweak until those share numbers climb.
When you customize both style and placement, you create social share buttons that not only blend in—they stand out right when your visitors are ready to take action.
Troubleshooting and Best Practices
Setting up custom Pinterest and Facebook share buttons with code keeps your site fast and tailored, but sometimes glitches pop up. When a button doesn’t show, doesn’t open the right dialog, or breaks your layout, you don’t want to panic. Let’s look at common issues and how to fix them, then cover simple steps to keep your share code running smoothly as your site grows.
Resolving Common Integration Issues
Adding code for share buttons is usually quick, but it’s normal to hit a snag or two. Most problems have simple solutions if you know where to look.
Photo by Anna Shvets
If your Pinterest or Facebook buttons aren’t working as expected, start troubleshooting with these steps:
- Check Your Code: Even a small typo—like a missing bracket or wrong URL—can break the button.
- Clear Your Caches: WordPress caching or browser cache can prevent the latest changes from showing up. Clear your caches and refresh.
- Theme or Plugin Conflicts: Other code or plugins may clash with your snippet. Disable other plugins temporarily to rule out conflicts, then turn them back on one by one.
Maintaining and Updating Your Social Share Button Code
Once your share buttons run smoothly, you’ll want to keep them that way. Good maintenance helps you avoid surprise errors after platform updates or theme changes.
Here’s how to keep your setup healthy:
- Backup Your Snippets: Keep a simple text file or cloud note with your share code snippets. If you ever switch themes or hosting, you can restore your code in minutes.
- Keep WPCode Lite Updated: Update the plugin itself for security patches and compatibility, just like any other plugin.
- Test After Major Updates: If you update WordPress, your theme, or major plugins, double-check that your share buttons still work. It saves trouble if something breaks.
Staying proactive with your code means fewer headaches and a better visitor experience—without plugin clutter slowing you down.
Congratulations on making the switch!
Switching to code for Pinterest and Facebook share buttons puts you in full control of your site. Using WPCode Lite, you skip plugin bloat and gain a faster, cleaner website that feels built just for you. This method lets you update, style, and place your buttons however you want, without risking slowdowns, privacy issues, or surprise bugs from third-party plugins.
You’re not just streamlining your site—you’re building a better experience for every visitor. To keep improving, explore best practices for WordPress speed and security.