linkedin 分享_如何在WordPress中添加官方LinkedIn共享按钮

linkedin 分享

Do you want to add the official LinkedIn share button in WordPress? There are many social media plugins 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共享按钮。

Adding LinkedIn share button in WordPress
在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 how to copy and paste code in WordPress.

对于本教程,您需要编辑WordPress主题文件。 如果您以前没有做过,请查看有关如何在WordPress中复制和粘贴代码的指南。

First, you need to visit the LinkedIn Share Plugin page. You will be asked to select your website’s language and the button style you want to use.

首先,您需要访问LinkedIn共享插件页面。 系统将要求您选择网站的语言和要使用的按钮样式。

You can leave the URL field blank because the share button can automatically get the page URL.

您可以将URL字段留空,因为共享按钮可以自动获取页面URL。

Next, you need to click on the ‘Get Code’ button to copy your LinkedIn share button code.

接下来,您需要单击“获取代码”按钮以复制您的LinkedIn共享按钮代码。

Copy the LinkedIn share button code

Now that we got the share code, let’s add the official buttons in your WordPress site.

现在我们已经获得了共享代码,让我们在您的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 functions.php file or in a site-specific plugin.

如果要在帖子内容之前显示LinkedIn共享按钮,则可以使用以下代码。 您将需要将此代码复制并粘贴到主题的functions.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');

You can save your changes and visit your website to see it in action.

您可以保存所做的更改并访问您的网站以查看实际操作。

LinkedIn Share button in action

If you want to display the share button after your post’s content, then you will need to add the following code instead.

如果要在帖子内容后显示“共享”按钮,则需要添加以下代码。



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 Appearance » Widgets page and add the ‘Custom HTML’ widget to a sidebar.

您还可以将您先前复制的LinkedIn共享按钮代码直接添加到WordPress自定义HTML小部件中。 只需访问外观»小部件页面,然后将“自定义HTML”小部件添加到侧边栏中。

Next, add your LinkedIn Share button code inside the custom HTML widget and click on the save button to store your changes.

接下来,将您的LinkedIn Share按钮代码添加到自定义HTML小部件中,然后单击“保存”按钮以存储您的更改。

Linkedin button in a sidebar widget

You can now visit your website to see it in action.

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

LinkedIn share button in sidebar

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 best LinkedIn plugins for WordPress.

我们希望本文能帮助您学习如何轻松地在WordPress中添加官方LinkedIn共享按钮。 您可能还希望查看我们的WordPress最佳LinkedIn插件列表。

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

如果您喜欢这篇文章,请订阅我们的YouTube频道 WordPress视频教程。 您也可以在TwitterFacebook上找到我们。

翻译自: https://www.wpbeginner.com/wp-tutorials/how-to-add-official-linkedin-share-button-in-wordpress/

linkedin 分享

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值