[Resolved] WPSP Social Icons (class="wpsp-social") shortcode?

Please login to receive premium support.

Support for the free plugin can be found here.

Home Forums Pro Support WPSP Social Icons (class="wpsp-social") shortcode?

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #1091
    Sebastian
    Participant

    Hi Tom, I would like to place the WPSP Social Icons (class=”wpsp-social”) in each post. Is there a Shortcode for this?

    Regards,
    Sebastian

    • This topic was modified 4 years ago by Sebastian.
    #1093
    Tom
    Keymaster

    Hi there,

    You mean in the single post itself (not WPSP)?

    Typically this plugin doesn’t add/modify the theme you’re using, it only affects the list of posts.

    However, you could try making a shortcode out of this function:

    if ( $social_sharing && function_exists( 'wpsp_social_sharing' ) ) :
    	echo wpsp_social_sharing( get_the_ID(), $twitter = true, $facebook = true, $googleplus = true, $pinterest = true, $love = true, $social_sharing_alignment = 'left' );
    	wp_enqueue_script( 'wpsp-love-it' );
    endif;
    #1101
    Sebastian
    Participant

    Hi Tom, yes exactly. I want to take social_sharing from WPSP and place it in a single post.

    I’ve tried, it does not work. I’m not a good coder, sorry 🙁 can you help me please?

    What am I doing wrong?

    add_shortcode( 'wpsp_social_sharing', 'wpsp_social_sharing_shortcode' );
    function wpsp_social_sharing_shortcode() { 
    	if ( $social_sharing && function_exists( 'wpsp_social_sharing' ) ) :
    		echo wpsp_social_sharing( get_the_ID(), $twitter = true, $facebook = true, $googleplus = true, $pinterest = true, $love = true, $social_sharing_alignment = 'left' );
    		wp_enqueue_script( 'wpsp-love-it' );
    	endif;
    }
    #1116
    Sebastian
    Participant

    I tried and it worked. But I do not understand one thing.

    get_the_title() is output at the exact location, where I placed the shortcode [xxx_wpsp_social_sharing] in the post content. The social icons, however, are at the top left on the website. Why?

    function wpsp_social_sharing_shortcode() {
    	return get_the_title() . wpsp_social_sharing( get_the_ID(), $twitter = true, $facebook = true, $googleplus = true, $pinterest = true, $love = true );
    	wp_enqueue_script( 'wpsp-love-it' );
    }
    add_shortcode( 'xxx_wpsp_social_sharing', 'wpsp_social_sharing_shortcode' );
    #1123
    Tom
    Keymaster

    Hmm, you could try this:

    function wpsp_social_sharing_shortcode() {
        ob_start();
        echo get_the_title() . wpsp_social_sharing( get_the_ID(), $twitter = true, $facebook = true, $googleplus = true, $pinterest = true, $love = true );
        wp_enqueue_script( 'wpsp-love-it' );
        $output_string = ob_get_contents();
        ob_end_clean();
    
        return $output_string;
    }
    add_shortcode( 'xxx_wpsp_social_sharing', 'wpsp_social_sharing_shortcode' );
    #1129
    Sebastian
    Participant

    Tom, you’re a genius, thanks 🙂

    #1130
    Tom
    Keymaster

    You’re welcome! 🙂

Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.