Trusted WordPress tutorials, when you need them most.
Beginner’s Guide to WordPress
Coupe WPB
25 Million+
Websites using our plugins
16+
Years of WordPress experience
3000+
WordPress tutorials
by experts

Comment ajouter le bouton de partage officiel de LinkedIn dans WordPress

Note éditoriale : Nous percevons une commission sur les liens des partenaires sur WPBeginner. Les commissions n'affectent pas les opinions ou les évaluations de nos rédacteurs. En savoir plus sur Processus éditorial.

Voulez-vous ajouter le bouton de partage officiel de LinkedIn dans WordPress ? Il existe de nombreuses extensions de réseaux sociaux qui vous permettent d’ajouter des boutons de partage, mais la plupart d’entre eux n’utilisent pas les boutons officiels. Dans cet article, nous allons vous afficher comment ajouter le bouton de partage officiel de LinkedIn dans WordPress.

Adding LinkedIn share button in WordPress

Ajout du bouton de partage officiel de LinkedIn sur WordPress

Pour ce tutoriel, vous aurez besoin de modifier les fichiers de votre thème WordPress. Si vous n’avez jamais fait cela auparavant, alors consultez notre guide sur la façon de copier et coller du code dans WordPress.

Tout d’abord, vous devez visiter la page de l’extension LinkedIn Share. Il vous sera demandé de sélectionner la langue de votre site et le style de bouton que vous souhaitez utiliser.

Vous pouvez laisser le champ URL vide car le bouton de partage peut obtenir automatiquement l’URL de la page.

Ensuite, vous devez cliquer sur le bouton  » Obtenir le code  » pour copier le code de votre bouton de partage LinkedIn.

Copy the LinkedIn share button code

Maintenant que nous avons obtenu le code de partage, ajoutons les boutons officiels dans votre site WordPress.

Afficher le bouton de partage LinkedIn dans les publications et pages WordPress

Si vous souhaitez afficher le bouton de partage LinkedIn avant le contenu de votre publication, alors vous pouvez utiliser le code suivant. Vous devrez copier et coller ce code dans le fichier functions.php de votre thème ou dans une extension spécifique à votre site.

function wpb_linkedin_share_before($content) { 
// Share code you copied from LinkedIn goes here
$sharecode .= '<script src="//platform.linkedin.com/in.js" type="text/javascript"> lang: en_US</script>
<script type="IN/Share" data-counter="top"></script>'; 
$newcontent = $sharecode .$content; 
return $newcontent; 
} 
add_filter('the_content', 'wpb_linkedin_share_before');

Vous pouvez enregistrer vos modifications et visiter votre site pour le voir en action.

LinkedIn Share button in action

Si vous souhaitez afficher le bouton de partage après le contenu de votre publication, vous devrez alors ajouter le code suivant à la place.


function wpb_linkedin_share_after($content) { 
$sharecode .= '<script src="//platform.linkedin.com/in.js" type="text/javascript"> lang: en_US</script>
<script type="IN/Share" data-counter="top"></script>'; 
$newcontent = $content . $sharecode; 
return $newcontent; 
} 
add_filter('the_content', 'wpb_linkedin_share_after');

Vous pouvez également ajouter le code du bouton de partage LinkedIn que vous avez copié plus tôt directement dans un widget HTML personnalisé de WordPress. Rendez-vous simplement sur la page Apparence  » Widgets et ajoutez le widget ‘HTML personnalisé’ à une colonne latérale.

Ensuite, ajoutez le code de votre bouton de partage LinkedIn à l’intérieur du widget HTML personnalisé et cliquez sur le bouton enregistrer pour stocker vos modifications.

Linkedin button in a sidebar widget

Vous pouvez maintenant visiter votre site pour le voir en action.

LinkedIn share button in sidebar

Nous espérons que cet article vous a aidé à apprendre comment ajouter facilement le bouton de partage officiel de LinkedIn dans WordPress. Vous pouvez également consulter notre liste des meilleures extensions LinkedIn pour WordPress.

Si vous avez aimé cet article, veuillez alors vous abonner à notre chaîne YouTube pour des tutoriels vidéo WordPress. Vous pouvez également nous trouver sur Twitter et Facebook.

Divulgation : Notre contenu est soutenu par les lecteurs. Cela signifie que si vous cliquez sur certains de nos liens, nous pouvons gagner une commission. Consultez comment WPBeginner est financé, pourquoi cela compte et comment vous pouvez nous soutenir. Voici notre processus éditorial.

Avatar

Editorial Staff at WPBeginner is a team of WordPress experts led by Syed Balkhi with over 16 years of experience in WordPress, Web Hosting, eCommerce, SEO, and Marketing. Started in 2009, WPBeginner is now the largest free WordPress resource site in the industry and is often referred to as the Wikipedia for WordPress.

L'ultime WordPress Toolkit

Accédez GRATUITEMENT à notre boîte à outils - une collection de produits et de ressources liés à WordPress que tous les professionnels devraient avoir !

Reader Interactions

29 commentairesLaisser une réponse

  1. Syed Balkhi says

    Hey WPBeginner readers,
    Did you know you can win exciting prizes by commenting on WPBeginner?
    Every month, our top blog commenters will win HUGE rewards, including premium WordPress plugin licenses and cash prizes.
    You can get more details about the contest from here.
    Start sharing your thoughts below to stand a chance to win!

  2. Sanket Bhardwaj says

    Hey, Thanks for providing this code. I have added this button on my website but now when i want to remove this It came back again and again. I have removed the code from functions.php but it came again and again.
    Please help Me.

  3. Gabriela says

    Anyone know why when you share your blog here in WordPress to LinkedIn, there is no picture attached? I do have one but it disappears when I try to share it to LinkedIn. I shared it in Facebook and Twitter and it works good but not in LinkedIn, The text appears good but no picture. I don’t get it. Tips? Thank you!

  4. Emily says

    Does anyone know of a way to add the LinkedIn share button to a « free » wordpress, for which I own the domaine? Not sure if this matters, but I think maybe the other company is « hosting » the wordpress page. Anyway, I’ve tried the text widget and adding the html to the end of a blog post. Don’t think either is working because I just get a weird looking hyperlink that takes someone to a page of text….

  5. Electra Ford says

    Hi,

    I’ve added the code but it’s not showing for me. Any new updates on how to get the LinkedIn share button to display?

    Thanks

  6. sinhrakesh says

    I used below codes in the Custom Codes section to add Google+ and Linkedin Share buttons on my WP Blog (www.maintec.com/blog):

    Google+

    <div class= »sharer »><script type= »text/javascript » src= »https://apis.google.com/js/plusone.js »></script> <g:plusone size= »tall »></g:plusone></div>

    Linkedin

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

    Google+ Button is working fine but Linkedin Share isn’t getting the desired result upon clicking… Can you please advise whats wrong where?

  7. wpbeginner says

    You are welcome. Yes horizontal one works great, but if you have a floating share box like ours, then the vertical share box is good too.

  8. Keith Aul says

    I’m not to sure what you mean by the following?
    To add the Official Linkedin Share button simply open up a theme file of your choice (single.php etc) and add the following code within the Post Loop

    I don’t want to break anything on my site so I want to be sure I’m able to find the right file and open/edit it. Where would I find the theme file in my dashboard and where in the file do I post the code?

    • Editorial Staff says

      You will find the theme file in your theme’s folder wp-content/themes/yourthemename/ < Editor and edit single.php file. If you have no knowledge regarding WordPress, then we recommend that you wait till a plugin comes out.

      Administrateur

  9. Piet says

    Finally LinkedIn did this, a week too late though, but I managed to make something similar for myself.
    Next time I need it, I will just grab your code, thanks!

    • Jose Joel says

      The Share This Plugin have the option to add the LinkedIn Button as simple as writing linkedin the editing section of the plugin…and this one have count… ;)

      Note: I’m not the developer of this plugin, neither work for them, I’m only a regular user… :)

  10. Jon Bishop says

    I’m happy LinkedIn finally did this. I tried to use their API to make my own for the Socialize plugin but it ended up being a pain. I was able to finally use this code to update the plugin with the new LinkedIn button.

Laisser une réponse

Merci d'avoir choisi de laisser un commentaire. Veuillez garder à l'esprit que tous les commentaires sont modérés selon notre politique de commentaires, et votre adresse e-mail ne sera PAS publiée. Veuillez NE PAS utiliser de mots-clés dans le champ du nom. Ayons une conversation personnelle et significative.