-
AuthorPosts
-
November 23, 2015 at 1:21 am #675605
I used this code in my functions.php
add_action('x_before_the_content_end', function() { echo do_shortcode('[share title="Share this Post" facebook="true" twitter="true" google_plus="true" linkedin="true" pinterest="true" reddit="true" email="true"]'); });
and it shows on all pages. I would like for it to only appear on my blog posts not on any other pages.
November 23, 2015 at 1:25 am #675613Hi there,
Please update your code to :
add_action('x_before_the_content_end', function() { if ( is_singular('post') ) { echo do_shortcode('[share title="Share this Post" facebook="true" twitter="true" google_plus="true" linkedin="true" pinterest="true" reddit="true" email="true"]'); } });
Hope that helps.
November 23, 2015 at 2:26 pm #676514I just put that in the functions.php and now get a server 500 error.
November 23, 2015 at 5:15 pm #676710Hi There,
Would you mind providing us with login credentials so we can take a closer look? To do this, you can make a post with the following info:
– Link to your site
– WordPress Admin username / password
– FTP credentialsDon’t forget to select Set as private reply. This ensures your information is only visible to our staff.
Thanks!
November 23, 2015 at 8:57 pm #676877This reply has been marked as private.November 23, 2015 at 11:54 pm #677020This reply has been marked as private.November 25, 2015 at 3:03 pm #679405X staff, you set a reply as private and i cannot see it if it was intended to help me! Thanks!
November 25, 2015 at 5:46 pm #679542Hi @nextleap,
I have try to login using the details you have provided but there are no files present in the directory. Kindly double check it. Thank you.
December 21, 2015 at 12:19 pm #716175If anyone else wonders… this solution works for me to get social shares on all blog posts, but nothing else.
https://community.theme.co/forums/topic/how-can-i-insert-social-share-in-my-blog-posts/#post-264848December 21, 2015 at 4:55 pm #716493Thanks for sharing Heine!
April 23, 2016 at 1:14 pm #896839I’m using the Renew stack, and want to add these JUST to posts, which is what I thought the o.p. meant, too. I added your code to the functions.php file, and it added the social sharing links to ALL pages, not just to posts. How do I ONLY have them appear on posts?
Here’s the code I used, from above:
add_action(‘x_before_the_content_end’, function() {
echo do_shortcode(‘[share title=”Share this Post” facebook=”true” twitter=”true” google_plus=”true” linkedin=”true” pinterest=”true” reddit=”true” email=”true”]’);
});April 24, 2016 at 11:00 am #897513Hi @eel,
Please try with this code instead:
add_action('x_before_the_content_end', function() { if(is_singular( 'post' )){ echo do_shortcode('[share title="Share this Post" facebook="true" twitter="true" google_plus="true" linkedin="true" pinterest="true" reddit="true" email="true"]'); } });
Hope it helps 🙂
-
AuthorPosts