wordpress添加媒体_如何在WordPress中添加Facebook Like Button

wordpress添加媒体

Do you want to add a Facebook Like button in WordPress? Facebook is the largest social media platform in the world. Using Facebook Like button, you can allow users to Like and share your content on Facebook. In this article, we will show you how to add the Facebook Like button in WordPress.

您是否要在WordPress中添加Facebook Like按钮? Facebook是世界上最大的社交媒体平台。 使用“ Facebook点赞”按钮,您可以允许用户在Facebook上点赞并分享您的内容。 在本文中,我们将向您展示如何在WordPress中添加Facebook Like按钮。

Facebook Like Button for WordPress
方法1:在WordPress中手动添加Facebook赞按钮 (Method 1: Manually Add Facebook Like Button in WordPress)

This method requires you to add the code directly in WordPress. If haven’t done it before, then please take a look at our beginner’s guide to pasting snippets from the web into WordPress.

此方法要求您直接在WordPress中添加代码。 如果以前没有做过,那么请看一下我们的初学者指南, 指南将网络上的摘要粘贴到WordPress中

First, you need to visit the Like button page on Facebook developers website and scroll down to ‘Like Button Configurator’ section.

首先,您需要访问Facebook开发人员网站上的“ 喜欢”按钮页面 ,然后向下滚动至“喜欢按钮配置器”部分。

Like button settings

Use the configuration to choose the Like button layout and size. You will see a preview of the Like button below.

使用配置选择“喜欢”按钮的布局和大小。 您将在下面看到“喜欢”按钮的预览。

You can leave the URL field empty, as we will dynamically fill in the URL in WordPress.

您可以将URL字段留空,因为我们将在WordPress中动态填写URL。

Once you are satisfied with the preview, click on the ‘Get Code’ button.

对预览感到满意后,单击“获取代码”按钮。

This will bring up a popup showing you two pieces of code snippets under the JavaScript SDK tab.

这将弹出一个弹出窗口,向您显示JavaScript SDK选项卡下的两个代码段。

Facebook Like button code generator

Copy the first code snippet and add it to your WordPress theme’s header.php file right after the <body> tag.

复制第一个代码段,并将其添加到<body>标记之后的WordPress主题的header.php文件中。

Next, you need to copy the second piece of code and paste it in your WordPress theme’s template files where you want to actually display the Like button.

接下来,您需要复制第二段代码并将其粘贴到您要实际显示“赞”按钮的WordPress主题模板文件中。

Most probably you will want to add it to single.php, archive.php, page.php, etc. However, if your WordPress theme uses content templates, then you will need to add it to content templates.

您很可能希望将其添加到single.php,archive.php,page.php等。但是,如果WordPress主题使用内容模板,则需要将其添加到内容模板。

Please note that if you directly add these code snippets to your WordPress theme, then they will be overwritten when you update the theme.

请注意,如果您直接将这些代码段添加到WordPress主题中,则在更新主题时它们将被覆盖。

You can avoid this, by creating a child theme and then adding these code snippets into your child theme templates.

您可以通过创建子主题然后将这些代码段添加到子主题模板中来避免这种情况。

方法2:使用插件在WordPress中添加Facebook赞按钮 (Method 2: Add Facebook Like Button in WordPress Using a Plugin)

In this method, we will be using a WordPress plugin to add Facebook Like button. This method is much easier and is recommended for beginners.

在这种方法中,我们将使用WordPress插件添加Facebook Like按钮。 此方法更加简单,建议初学者使用。

First thing you need to do is install and activate the WP Like Button plugin. For more details, see our step by step guide on how to install a WordPress plugin.

您需要做的第一件事是安装并激活WP Like Button插件。 有关更多详细信息,请参阅有关如何安装WordPress插件的分步指南。

Upon activation, the plugin will add a new menu item labeled WP Like Button to your WordPress admin bar. Clicking on it will take you to plugin’s settings page.

激活后,该插件将在WordPress管理栏中添加一个名为WP Like Button的新菜单项。 单击它会将您带到插件的设置页面。

WP Like Button settings

First you need to select where you want to display the Like button and choose whether you want the button to be mobile responsive or not.

首先,您需要选择要显示“赞”按钮的位置,然后选择是否希望该按钮具有移动响应功能。

Next, you need to provide a Facebook App ID or an Admin ID of a user who has access to Facebook insights. You can use your own Facebook username or ID here.

接下来,您需要提供有权访问Facebook见解的用户的Facebook App ID或Admin ID。 您可以在此处使用自己的Facebook用户名或ID。

Under the default image setting, you can upload an image that will be used when a post or page does not have a Facebook thumbnail. Leave this option, we will show you how to set Facebook thumbnail later in this article.

在默认图像设置下,您可以上传在帖子或页面没有Facebook缩略图时将使用的图像。 保留此选项,我们将在本文后面向您展示如何设置Facebook缩略图。

Under ‘What to like’ option, you need to select ‘Each page/post will have its own like button’. After that you need to select a layout, alignment, language, for your Facebook button.

在“喜欢的东西”选项下,您需要选择“每个页面/帖子都有自己的喜欢按钮”。 之后,您需要为Facebook按钮选择一种布局,对齐方式,语言。

At the bottom of the page, you will be able to see a preview of how the button will appear on your site.

在页面底部,您将可以预览按钮在网站上的显示方式。

Once you are finished, click on the ‘Save Settings’ button to store your changes.

完成后,单击“保存设置”按钮以存储您的更改。

That’s all, you can now visit your WordPress site and you will see the Like button for each post.

就是这样,您现在可以访问WordPress网站,并且每个帖子都会显示“赞”按钮。

Like button in WordPress
什么是开放图元数据? 如何在WordPress中添加 (What is Open Graph Meta Data? How to Add it in WordPress)

Open Graph meta data helps Facebook collect meta information about a page or post on your WordPress site. This data includes a thumbnail image, post/page title, description and author.

开放图元数据可帮助Facebook收集有关页面或在WordPress网站上发布的元信息。 此数据包括缩略图,帖子/页面标题,描述和作者。

Facebook is quite smart in pulling up the title and description fields. However, if your post has more than one image, then sometimes it shows incorrect thumbnail when your article is shared.

Facebook非常擅长提取标题和描述字段。 但是,如果您的帖子有多个图像,则有时在共享您的文章时会显示不正确的缩略图。

If you are already using Yoast SEO plugin, then this can be easily fixed by visiting SEO » Social page and clicking on the Facebook tab.

如果您已经在使用Yoast SEO插件,则可以通过访问SEO»社交页面并单击Facebook选项卡轻松解决此问题。

Facebook Open Graph

For more details and alternate ways to add open graph meta data, see our guide on how to add Facebook Open Graph meta data in WordPress.

有关更多详细信息和添加开放式图形元数据的替代方法,请参阅有关如何在WordPress中添加Facebook开放式图形元数据的指南

That’s all, we hope this article helped you learn how to add Facebook Like button in WordPress. You may also want to see our list of 10 best Facebook tips and tutorials for WordPress users.

仅此而已,我们希望本文能帮助您学习如何在WordPress中添加Facebook Like按钮。 您可能还想查看我们为WordPress用户提供10个最佳Facebook技巧和教程的列表。

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-facebook-like-button-in-wordpress/

wordpress添加媒体

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值