Bit of help with social sharing code

Hi,

I found this code to add social sharing in another thread and it works, but I would like the icons to be in between the post title and the content. How do I alter the code so that is is loaded there?

    // Add Social Sharing after the single post content
// =============================================================================

function x_add_social_sharing ( $content ) {
  if ( is_singular('post') ) {
    echo do_shortcode('[share title="Delen" facebook="true" twitter="true" google_plus="true" linkedin="true" pinterest="true" email="true"]');
  }
}
add_action('x_before_the_content_end', 'x_add_social_sharing');

Hello @Foxon,

Thanks for asking. :slight_smile:

Placing social icons in between post title and content fall outside the scope of the support we offer as it require custom development. However I can share necessary steps that you can take to make required changes.

Integrating social icons in between title and content requires making modification in template files. For that I highly suggest you to please install and setup child theme. To download child theme please use following resource. I am also sharing documentation we have published that you can refer to learn more about setting up child theme and best practices we suggest:

https://theme.co/apex/child-themes

Once you have installed child theme, please navigate to /wp-content/themes/x/framework/views/renew/ and copy _content-post-header.php file and paste under /wp-content/themes/x-child/framework/views/renew/. You may need to create necessary child folder. Over here I am taking our Renew stack as an example. You are supposed to navigate to the relevant stack folder that you are using on the website.

Next, you need to paste following code after line number 13 that startes with <h1 class="entry-title">. Here is the code that you can use:

<?php echo do_shortcode('[share title="Delen" facebook="true" twitter="true" google_plus="true" linkedin="true" pinterest="true" email="true"]'); ?>

Over here we have used do_shortcode, if you would like to learn more please refer following documentation:

https://developer.wordpress.org/reference/functions/do_shortcode/

Save the changes and upload the files. Hope that helps you to get started.

Thanks.

1 Like

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