How do i add social share element on my blog posts

Hi there community!

I was wondering how does one add the social share element on all their blog posts. I was able to achieve this on my other site but not here for some reason?

Also, how do I change the way my blog is categorized, i would like it to be categorized by date…currently its all over the place and not by date

Hi Carolina,

Thank you for reaching out to us. To add the social share element on all your blog posts, add the following code in your child theme’s functions.php file

function x_add_social_sharing() {
		if ( is_single() ) {
  			echo do_shortcode('[x_share title="Share this Post" facebook="true" twitter="true" google_plus="true" linkedin="true" pinterest="true" reddit="true" email="true"]');
		}
}
add_action('x_before_the_content_end', 'x_add_social_sharing');

To order your blog posts you can try the following plugin https://wordpress.org/plugins/post-types-order/

Hope this helps!

Awesome!! worked well, i changed it to the social posts I would want it to be shared on but i want to change the title to share the news.I updated the code to:

function x_add_social_sharing() {
if ( is_single() ) {
echo do_shortcode(’[x_share title="Share the News” facebook=“true” twitter=“true” google_plus=“true” linkedin=“true” email=“true”]’);
}
}
add_action(‘x_before_the_content_end’, ‘x_add_social_sharing’);

but the title is not changing

Hi Carolina,

Have you tried clearing your server cache and browser cache? The only change is the title and it shouldn’t cause any issue. For the meantime, could you try changing this if ( is_single() ) {

to this if ( is_singular('post') ) {

Thanks!

You are right! it was my cache. Thank you

You’re welcome!
Thanks for letting us know that it has worked for you.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.