Navigation
This is archived content. Visit our new forum.
  • Author
    Posts
  • #675605

    NextLeap
    Participant

    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.

    #675613

    Christopher
    Moderator

    Hi 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.

    #676514

    NextLeap
    Participant

    I just put that in the functions.php and now get a server 500 error.

    #676710

    Friech
    Moderator

    Hi 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 credentials

    Don’t forget to select Set as private reply. This ensures your information is only visible to our staff.

    Thanks!

    #676877

    NextLeap
    Participant
    This reply has been marked as private.
    #677020

    Christopher
    Moderator
    This reply has been marked as private.
    #679405

    NextLeap
    Participant

    X staff, you set a reply as private and i cannot see it if it was intended to help me! Thanks!

    #679542

    Jade
    Moderator

    Hi @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.

    #716175

    heine
    Participant

    If 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-264848

    #716493

    Rad
    Moderator

    Thanks for sharing Heine!

    #896839

    E
    Participant

    I’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”]’);
    });

    #897513

    Thai
    Moderator

    Hi @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 🙂