0

Really simple question here.

I've spent the last 5 hours going through all the social plugins on WordPress. There are only a very few who allow custom placement using a shortcode block [shortcode] or a PHP function functionrun();.

I managed to get 3 of them working and integrated, but on each one the Facebook sharing was broken, yet twitter + LinkedIn and more worked perfectly fine. Strange I thought, but moved on to others.

I've actually gone through nearly every decent one out there and I'm still stumped. I'd rather just use my own code but Facebook sharing seems to be quite tedious to get right, twitter is very simple.

Im just looking for opinions here on what I should do next.

I need the ability to place Facebook/Twitter/LinkedIn sharing icons on any template I choose using either shortcut or a block of code. I need the sharing to work, that's it. Quite simple but super difficult to find...

Thanks for the time

1

Here is a quick shortcode for you. You'll still have to style it the way you want it.
Just use:[social-share] to share.

// social sharing shortcode, use [social-share]
add_shortcode( 'social-share', 'render_social_share' );

function render_social_share( $atts ){

    $social_output = '<p>Share on:</p>
    <ul>
        <li><a href="https://www.facebook.com/sharer/sharer.php?u=' . get_the_permalink() . '" target="_blank">Facebook</a></li>
        <li><a href="https://twitter.com/share?text=' . get_the_title() . '&url=' . get_the_permalink() . '" target="_blank">Twitter</a></li>
        <li><a href="https://www.linkedin.com/cws/share?url=' . get_the_permalink() . '" target="_blank">LinkedIn</a></li>
    </ul>';

    return $social_output;

}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.