AddThis Related Posts

Hi there!

I installed the AddThis Related Posts plugin on my site (Ethos) and I should add a div with some code in all the blog articles pages. How should I proceed?
My child theme is active on my website.

Kind regards,

Marco

Hi Marco,

Would you mind specifying which part of the post pages you want to add the div and what is code you will have to add so that we could provide some suggestions?

Thank you.

Hi Jade!
Thank for your reply.

I should add this code:
`

`

And I should insert it in the end of articles of the blog.

Thank you

Hi there,

If you want to add the code for the single blog posts then you need to add the code below to functions.php:

add_filter( 'the_content', 'custom_add_this');
 
function custom_add_this($content) {
   if ( is_single() ) {
      return $content . '<div class="addthis_relatedposts_inline"></div>';
   } else {
      return $content;
   }
}

That will add the code to the end of the blog posts on the single page.

Thank you.

1 Like

Many thanks!!

Best regards

Marco

You’re welcome! :slight_smile:

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