LinkedIn Share Post Button

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.

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

div class="linkedInButton"a class="linkedIn"href="javascript:void(0)"onclick="window.open( 
'http://www.linkedin.com/shareArticle?mini=trueamp;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

Topic single blog php posts Wordpress

Category Web


Use this:

 <script type="text/javascript" 
 src="http://platform.linkedin.com/in.js"></script><script 
 type="in/share" data-url="<?php the_permalink(); ?>" 
 data-counter="right"></script>

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.