0

I made these custom social share buttons on my Divi site following the instructions from this blog post: https://diviwebsiteexpert.com/how-to-create-divi-social-share-buttons/

They all work fine, except the LinkedIn button stopped working within the past few days. Now when you click it, a new tab opens to a page that says, "Something went wrong." A block of Javascript at the bottom of the body section relates to social buttons below the featured image using jQuery. Here's the code:

// Setup Function
var $jq = jQuery.noConflict();
$jq(document).ready(function() {

// Facebook
var FB_share = "https://www.facebook.com/sharer/sharer.php?u="+encodeURIComponent(document.URL)+"&t="+encodeURIComponent(document.URL);

$jq('.fb-social-share').each(function(){
this.href=FB_share;
});

// Twitter Share
var twitter_Share = "https://twitter.com/intent/tweet?text=%20Check%20up%20this%20awesome%20content%20" + encodeURIComponent(document.title)+":%20 "+encodeURIComponent(document.URL);

$jq('.twitter-social-share').each(function(){
this.href=twitter_Share;
});

//Linkedin
var Linkedin_Share = "http://www.linkedin.com/shareArticle?mini=true&title="+encodeURIComponent(document.URL)+"&title="+encodeURIComponent(document.title);

$jq('.linkedin-social-share').each(function(){
this.href=Linkedin_Share ;
});

//Email
var email_Share = "mailto:?subject="+encodeURIComponent(document.title)+"&body="+encodeURIComponent(document.URL);
$jq('.email-social-share').each(function(){
this.href=email_Share ;
});

});

</script>

I followed steps outlined in another post here.

And I also referred to the official LinkedIn documentation here.

But so far nothing has helped. Anyone have suggestions?

frrstbrwn
  • 1
  • 1
  • Offtopic... use `$jq($ => { /* DOM ready and $ alias in scope */ });` and safely use inside the `$` alias (instead of `$jq`) ;) Or for short: `jQuery.noConflict()($ => { });` – Roko C. Buljan Apr 13 '22 at 22:49

1 Answers1

2

For your LinkedIn section, it should be this:

var Linkedin_Share = "http://www.linkedin.com/shareArticle?mini=true&url="+encodeURIComponent(document.URL)+"&title="+encodeURIComponent(document.title);

You have title= in both spots and you need to specify url= in order for the link to work.