Hi there I have been having trouble with a LinkedIn custom share button. My theme didn't seem to provide one and I like this theme so wanted to create my own.

I have gotten as far as getting a window to open that signs you in to LinkedIn and takes you to post about something, I just can't get the code to work so it also inputs the URL of the WordPress single post you are currently visiting.

Here is my code, this is what I am putting at the bottom of my single_post.php, thank you.

$Url = (@$_SERVER["HTTPS"] == "on") ? "https://" : "http://";

<div class="linkedInButton"><a class="linkedIn"href="javascript:void(0)"onclick="window.open( 
'http://www.linkedin.com/shareArticle?mini=true&amp;url=<?php echo $Url;
 ?>', 'sharer', 'toolbar=0, status=0, width=626, height=436');return false;
" title="Linkedin"><button class="linkedInButton">
<span class="character"><img class="linkedInShare" 
src="uploads/2018/09/linkedin-logo.png">Share on LinkedIn</span></button></a></div>

Use this:

 <script type="text/javascript" 
 type="in/share" data-url="<?php the_permalink(); ?>" 
  • Please edit your answer, and add an explanation: why could that solve the problem? – fuxia Sep 11 '18 at 9:56
  • Nothing comes up in the post. Is this the one from the official LinkedIn site, as I have tried that before with no luck. I added the code and there is nothing showing up. I already have a decent site of code that opens a new window and allows you to sign into LinkedIn, if needed, and make a post. All I need is the url of that page transferred into the LinkedIn post box. So you can then write a comment on the link you are sharing (that particular blog post) – idwithin Sep 11 '18 at 11:38

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.