wordpress谷歌字体_如何在WordPress网站中添加Google搜索

wordpress谷歌字体

Do you want to use Google search on your WordPress site? Although WordPress comes with a built-in search feature, it is not very good. That’s why many site owners add Google site search on their WordPress site. In this article, we will show you how to easily add Google Search in a WordPress site.

您要在WordPress网站上使用Google搜索吗? 尽管WordPress具有内置的搜索功能,但它不是很好。 这就是为什么许多网站所有者在其WordPress网站上添加Google网站搜索的原因。 在本文中,我们将向您展示如何在WordPress网站中轻松添加Google搜索。

How to Add Google Search in WordPress
为什么要在WordPress中使用Google搜索? (Why You Should Use Google Search in WordPress?)

The default WordPress search feature is not very useful. It often fails to find the relevant results. This forces site owners to look for alternatives.

默认的WordPress搜索功能不是很有用。 通常找不到相关结果。 这迫使网站所有者寻找替代方案。

There are plenty of search plugins for WordPress like SearchWP, Swiftype, etc. The problem is that you still have to manage them, and they will have an impact on your server resources.

有很多适用于WordPress搜索插件,例如SearchWPSwiftype等。问题是您仍然必须对其进行管理,并且它们会影响服务器资源。

On the other hand, you can use Google’s reliable and powerful search feature instead. It is free, allows you to limit the search to your sites only, and can be run from your own site.

另一方面,您可以改用Google可靠而强大的搜索功能。 它是免费的,允许您将搜索限制在您的网站上,并且可以从您自己的网站运行。

Other benefits of using Google search are speed, users already trust Google brand, and you will not have to maintain or update it.

使用Google搜索的其他好处是速度快,用户已经信任Google品牌,因此您无需维护或更新它。

Having said that, let’s see how you can easily add Google site search to your WordPress site.

话虽如此,让我们看看如何轻松地将Google网站搜索添加到WordPress网站。

To make it easy, we have created a video tutorial on how to add Google search that you can watch below.

为简单起见,我们创建了一个视频教程,介绍如何添加Google搜索,您可以在下面观看。

演示地址

However if you just want to follow text-instructions, then you can follow our step by step tutorial on how to add Google search in a WordPress site.

但是,如果您只想按照文本说明进行操作,则可以按照有关如何在WordPress网站中添加Google搜索的分步教程进行操作。

方法1:使用插件在WordPress中添加Google搜索 (Method 1: Adding Google Search in WordPress with Plugin)

This first method is easier and recommended for beginners. It allows you to add Google search to your WordPress site without modifying your theme files.

第一种方法比较简单,建议初学者使用。 它允许您将Google搜索添加到WordPress网站,而无需修改主题文件。

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

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

Upon activation, you need to visit Settings » WP Google Search to setup the plugin.

激活后,您需要访问设置»WP Google搜索以设置插件。

Settings page for WP Google Search

The plugin will ask you to provide a Google Search Engine id. Here is how you will get a search engine ID.

插件将要求您提供一个Google搜索引擎ID。 这是您将获得搜索引擎ID的方法。

Visit Google Custom Search website and click on New Search Engine link on the left.

访问Google自定义搜索网站,然后单击左侧的“新建搜索引擎”链接。

Creating new Google Custom Search engine for your WordPress site

Simply provide your WordPress site’s URL in ‘Sites to Search’ field. Next, you need to choose the language of your website. Lastly, click on the create button to continue.

只需在“搜索站点”字段中提供WordPress站点的URL。 接下来,您需要选择网站的语言。 最后,单击创建按钮继续。

Google will now create your custom search engine and will show you a success message with links to further actions. You need to click on the control panel button to continue editing your search engine.

Google现在将创建您的自定义搜索引擎,并向您显示一条成功消息,其中包含进一步操作的链接。 您需要单击控制面板按钮以继续编辑搜索引擎。

go to Google custom search engine's control panel

This will take you to the control panel for your custom search engine. First, you need to click on the ‘Search engine ID’ button and copy your search engine ID.

这将带您进入自定义搜索引擎的控制面板。 首先,您需要点击“搜索引擎ID”按钮并复制您的搜索引擎ID。

Copy your Google custom search engine ID

Next, you need to click on the ‘Look and Feel’ section. Under the layout tab, select results only.

接下来,您需要点击“外观”。 在布局标签下,仅选择结果。

Choose layout for search results page

Once you are done, click on the save button at the bottom of the page to store your changes.

完成后,单击页面底部的保存按钮以存储您的更改。

Now you can switch back to your WordPress site. Paste the search engine ID you copied earlier in the WP Google Search’s settings page and then click on the save changes button to store plugin settings.

现在,您可以切换回WordPress网站。 将您先前复制的搜索引擎ID粘贴到WP Google搜索的设置页面中,然后单击“保存更改”按钮以存储插件设置。

After that you need to visit Appearance » Widgets page. There you will notice WP Google Search widget in the list of available widgets. Drag and drop the widget to a sidebar where you want to display the search form.

之后,您需要访问外观»小部件页面。 在那里,您会在可用小部件列表中注意到WP Google搜索小部件。 将小部件拖放到要显示搜索表单的侧边栏。

Google custom search engine widget

Click on the save button to store your widget settings.

单击保存按钮以存储小部件设置。

You can now visit your website to see the search form in action.

现在,您可以访问您的网站以查看搜索表单。

Google custom search form in WordPress
方法2:在WordPress中手动添加Google搜索 (Method 2: Manually Adding Google Search in WordPress)

This method requires making changes to your WordPress theme or child theme files. It is not recommended for beginners. Make sure to backup your WordPress site before making any changes to your theme files.

此方法需要更改WordPress主题或子主题文件。 不建议初学者使用。 对主题文件进行任何更改之前,请确保备份WordPress网站

Visit Google Custom Search website and click on New Search Engine link on the left.

访问Google自定义搜索网站,然后单击左侧的“新建搜索引擎”链接。

Creating new Google Custom Search engine for your WordPress site

Simply provide your WordPress site’s URL in ‘Sites to Search’ field. Next, you need to choose the language of your website. Lastly, click on the create button to continue.

只需在“搜索站点”字段中提供WordPress站点的URL。 接下来,您需要选择网站的语言。 最后,单击创建按钮继续。

Google will now create your custom search engine and will show you a success message with links to further actions. You need to click on the Get Code button to continue.

Google现在将创建您的自定义搜索引擎,并向您显示一条成功消息,其中包含进一步操作的链接。 您需要单击“获取代码”按钮才能继续。

Get code for your Google custom search engine

On the next screen, you will see some code in a textarea. You need to copy this code.

在下一个屏幕上,您将在文本区域中看到一些代码。 您需要复制此代码。

For this next step, you will need an FTP client. If you need help, then see our guide on how to use FTP to upload WordPress files.

对于下一步,您将需要FTP客户端 。 如果您需要帮助,请参阅有关如何使用FTP上传WordPress文件的指南

Connect to your website using FTP and then go to /wp-content/themes/your-current-theme/ folder. Replace your current theme folder with the name of your current theme.

使用FTP连接到您的网站,然后转到/wp-content/themes/your-current-theme/文件夹。 将当前主题文件夹替换为当前主题的名称。

Editing searchform file

Locate the searchform.php file in your WordPress theme directory. Download this file to your computer and open it in a plain text editor like Notepad.

在WordPress主题目录中找到searchform.php文件。 将此文件下载到您的计算机,然后在纯文本编辑器(如记事本)中打开它。

Delete all contents of the file and paste your Google custom search engine code. Save the file and then upload it to back to your WordPress site using FTP.

删除文件的所有内容,然后粘贴您的Google自定义搜索引擎代码。 保存文件,然后使用FTP将其上传回WordPress网站。

After pasting Google custom search code, go to Appearance » Widgets to drag and drop the Search widget into your sidebar.

粘贴Google自定义搜索代码后,转到外观»小部件,将“搜索”小部件拖放到侧边栏中。

Adding search widget

Click on the save button to store your widget settings.

单击保存按钮以存储小部件设置。

You can now visit your website to see the Google search in action on your WordPress site.

现在,您可以访问您的网站,以查看在WordPress网站上进行的Google搜索。

自定义Google自定义搜索引擎的颜色和外观 (Customizing Google Custom Search Engine Colors and Looks)

Go to Google Custom Search website and edit your search engine. This will show settings for your custom search engine. Click on Look and Feel from sidebar.

转到Google自定义搜索网站并编辑搜索引擎。 这将显示您的自定义搜索引擎的设置。 在侧边栏中单击外观。

Google custom search has some pre-made themes available to choose from. You can also click on customize tab and choose your own font, border, and background colors.

Google自定义搜索有一些预制主题可供选择。 您也可以单击“自定义”选项卡,然后选择自己的字体,边框和背景颜色。

Customize colors and appearance of Google custom search

Once you are done customizing the look of your search box, simply save your changes. You don’t need to paste the code again, these changes will be automatically applied to your search form.

完成自定义搜索框外观后,只需保存更改即可。 您无需再次粘贴代码,这些更改将自动应用于您的搜索表单。

We hope this article helped you learn how to add Google search in a WordPress site. You may also want to see our list of 19+ free Google tools every WordPress blogger should use.

我们希望本文能帮助您学习如何在WordPress网站中添加Google搜索。 您可能还希望查看我们的列表,每个WordPress博客作者都应使用19种免费Google工具

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-google-search-in-a-wordpress-site/

wordpress谷歌字体

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值