Archived topic
Social Share Button only in Post
5 replies · Started by Lilia on January 9, 2020
Dear Generatepress Team,
I have this Function but I need Social Share button only in my Post (I will exclude social share button from Sites and Blog list) - and will also show Social Share button in any language in Post !
function add_social_share() {
echo do_shortcode("[fl_builder_insert_layout slug='social_buttons']");
}
add_action('generate_after_content','add_social_share',10,3);
I will show Social Share button in these sites
https://www.eu-rights.com/reisewarnung-tuerkei-urlaub-sicher-reisen/ (here is online)
and here
https://www.eu-rights.com/tr/vize-danismanlik-sirketi-tuerkiye/ (but isn't online)
on these pages I want to disable it Social Share button
https://www.eu-rights.com
https://www.eu-rights.com/flugverspaetung/
Can you help me?
Many thanks for your Time
lili
Hi there,
you can use the Hook Element:
https://docs.generatepress.com/article/hooks-element-overview/
To output your shortcode e.g.
echo do_shortcode("[fl_builder_insert_layout slug='social_buttons']");
hi David, many thx for your fast massage!
do you mean like this? I put this code in a Hook
add_action( 'social_share','social_share' );
function social_share() { ?>
echo do_shortcode("[fl_builder_insert_layout slug='social_buttons']");
<?php }
unfortunately this does not work
many thx for your help
You only need to echo the shortcode:
<?php echo do_shortcode("[fl_builder_insert_layout slug='social_buttons']"); ?>
Make sure to check execute PHP and Shortcodes.
:) Dear David, thank you!
I create a Hook for two language !
for German works !
https://www.eu-rights.com/flughafen-sabiha-goekcen-flug-storniert/
but second hook dont work!
https://www.eu-rights.com/tr/ucus-roetarlarinda-yolcu-sorumluluklari/
do you have any idea?
thx for your Time
Hi there,
Are you sure the Display Rules are correct? You can add some random text into the hook content to see if it shows up.