Sharing WordPress blog post on LinkedIn

I have this code, to share my blog post to LinkedIn:

<a href="https://www.linkedin.com/shareArticle?mini=true&url=<?php echo urlencode(get_permalink());?>&source=testing" onClick="return popup(this, 'posts')" data-url="<?php echo the_permalink($post->ID); ?>"class="button share-social share-linkedin" title="Share on LinkedIn"></a>

It shows my blog title correctly in the share popup, but “source” is not displayed, and i am unable to show the blog post image in the Linkedin share popup?

Read More

Is it the correct way to give the PHP code inside the URL?

Does anyone have a better idea?

Related posts

1 comment

  1. Click to share
    Store the url that you need share in $url and then

    <?php
    $url=get_permalink();
    ?>
    <a href="https://www.linkedin.com/cws/share?url=".<?php echo $url; ?>.">Click to share</a>
    

Comments are closed.