User Tools

Site Tools


How to add social media share buttons

You may want to add share buttons for social media sites to your blog, so your visitors can easily share your content to their followers.

The following solution for that was originally provided by Panther on the support forum. Thanks a lot!

1.: Upload images

At first, upload images for each share button you'd like to add. In our case, let's assume you create an sharebuttons folder in your FlatPress root. (Of course, you could store those images anywhere else within your FP instance).

2.: Add share buttons code to your theme

Open fp-interface/themes/your_theme/entry-default.tpl in the editor of your choice and add the following to where you want your share buttons to be shown. (Change this code to your needs: Remove the buttons you don't need, or add more. Instead of the width and height attributes, you could also use CSS classes.)

<div id="sharebuttons">
<a href="{$id|link:post_link}&title={$subject|tag:the_title}" target="_blank">
<img src="/sharebuttons/facebook.png" border="0" alt="Facebook" width="40" height="40">
<a href="{$subject|tag:the_title}&url={$id|link:post_link}" target="_blank">
<img src="/sharebuttons/twitter.png" border="0" alt="Twitter" width="40" height="40" >
<a href="whatsapp://send?text={$subject|tag:the_title} {$id|link:post_link}" data-action="share/whatsapp/share" target="_blank">
<img src="/sharebuttons/whatsapp.png" border="0" alt="Whatsapp" width="40" height="40">
<a href="fb-messenger://share/?link={$id|link:post_link}&app_id=your-app-id-here" target="_blank">
<img src="/sharebuttons/messenger.png" border="0" alt="Messenger" width="40" height="40">
<a href="{$id|link:post_link}&text={$subject|tag:the_title}" target="_blank">
<img src="/sharebuttons/telegram.png" border="0" alt="Telegram" width="40" height="40">
<a href="{$id|link:post_link}&description={$subject|tag:the_title}" count-layout="horizontal" target="_blank">
<img src="/sharebuttons/pinterest.png" border="0" alt="Pinterest" width="40" height="40">
<a href="{$id|link:post_link}&title={$subject|tag:the_title}" target="_blank">
<img src="/sharebuttons/linkedin.png" border="0" alt="Linkedin" width="40" height="40">
<a href="{$id|link:post_link}" target="_blank">
<img src="/sharebuttons/tumblr.png" border="0" alt="Tumblr" width="40" height="40">
<a href="{$id|link:post_link}&title={$subject|tag:the_title}" target="_blank">
<img src="/sharebuttons/reddit.png" border="0" alt="Reddit" width="40" height="40">
<a href="mailto:?subject={$subject|tag:the_title}&amp;body={$id|link:post_link}" title="{$subject|tag:the_title}">
<img src="/sharebuttons/email.png" border="0" alt="Email" width="40" height="40">

Alternative without images

Tongara altered Panther's approach by using FontAwesome icons instead of images for the buttons. See this solution on the forum.

doc/tips/sharebuttons.txt · Last modified: 2020/06/06 13:55 by arvid