
领英分享
Do you want to add the official LinkedIn share button in WordPress? There are many 社交媒体插件 that let you add share buttons, but most of them don’t use the official buttons. In this article, we will show you how to add the official LinkedIn share button in WordPress.
您是否要在WordPress中添加官方LinkedIn共享按钮? 有许多社交媒体插件可让您添加共享按钮,但其中大多数不使用官方按钮。 在本文中,我们将向您展示如何在WordPress中添加官方LinkedIn共享按钮。

在WordPress中添加官方LinkedIn共享按钮 (Adding Official LinkedIn Share Button in WordPress)
For this tutorial you’ll need to edit your WordPress theme files. If you haven’t done this before, then check out our guide on 如何在 WordPress 中复制和粘贴代码.
对于本教程,您需要编辑WordPress主题文件。 如果您以前没有做过,请查看有关如何在 WordPress 中复制和粘贴代码指南。
First, you need to visit the LinkedIn 分享插件 page. You will be asked to select your website’s language and the button style you want to use.
首先,您需要访问LinkedIn 分享插件页面。 系统将要求您选择网站的语言和要使用的按钮样式。
您可以将 URL 字段留空,因为共享按钮可以自动获取页面 URL。
您可以将 URL 字段留空,因为共享按钮可以自动获取页面 URL。
接下来,您需要单击“获取代码”按钮来复制 LinkedIn 共享按钮代码。
接下来,您需要单击“获取代码”按钮来复制 LinkedIn 共享按钮代码。

现在我们已经获得了共享代码,让我们在您的 WordPress 网站中添加官方按钮。
现在我们已经有了共享代码,让我们将官方按钮添加到您的 WordPress 网站。
在WordPress帖子和页面中显示LinkedIn共享按钮 (Display LinkedIn Share Button in WordPress Posts and Pages)
If you want to display the LinkedIn share button before your post content, then you can use the following code. You will need to copy and paste this code into your theme’s 函数.php file or in a 特定于站点的插件.
如果要在帖子内容之前显示LinkedIn共享按钮,则可以使用以下代码。 您将需要将此代码复制并粘贴到主题的函数.php文件或具体的于在网站的插件中 。
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');
您可以保存更改并访问您的网站以查看其实际效果。
您可以保存更改并访问您的网站以查看它们的实际效果。

如果您想在帖子内容之后显示分享按钮,则需要添加以下代码。
如果想在帖子内容后显示分享按钮,则需要添加以下代码。
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');
You can also add the LinkedIn share button code you copied earlier directly into a WordPress custom HTML widget. Simply visit 外观 » 小部件 page and add the ‘Custom HTML’ widget to a sidebar.
您还可以将您先前复制的LinkedIn共享按钮代码直接添加到WordPress自定义HTML小部件中。 只需访问外观 » 小部件页面,然后将“自定义HTML”小部件添加到侧边栏中。
接下来,在自定义 HTML 小部件中添加您的 LinkedIn 共享按钮代码,然后单击保存按钮来存储您的更改。
接下来,将您的 LinkedIn 共享按钮代码添加到自定义 HTML 小部件,然后单击“保存”按钮来存储您的更改。

您现在可以访问您的网站以查看其运行情况。
现在您可以访问您的网站以查看其运行情况。

We hope this article helped you learn how to easily add the official LinkedIn share button in WordPress. You may also want to see our list of the 适用于 WordPress 的最佳 LinkedIn 插件.
我们希望本文能帮助您学习如何轻松地在WordPress中添加官方LinkedIn共享按钮。 您可能还希望查看我们适用于 WordPress 的最佳 LinkedIn 插件列表。
If you liked this article, then please subscribe to our YouTube 频道 for WordPress video tutorials. You can also find us on 推特 and Facebook.
如果您喜欢这篇文章,请订阅我们的YouTube 频道 WordPress视频教程。 您也可以在推特和Facebook上找到我们。
翻译自: https://www.wpbeginner.com/wp-tutorials/how-to-add-official-linkedin-share-button-in-wordpress/
领英分享