WordPress小部件:它们是什么以及如何使用它们?

Many WordPress beginners are a little unsure about what widgets are and how to use them. To help, this article will give a detailed overview of widgets, show you how to incorporate them into your webpages and give you an understanding of the ways they can enhance your site.

许多WordPress初学者不确定什么是小部件以及如何使用它们。 为了提供帮助,本文将对小部件进行详细概述,向您展示如何将其合并到您的网页中,并使您了解它们可以如何增强您的网站。

网页的组成 (Components of a web page)

To get a proper understanding of widgets we need to look at the components of a webpage.

为了正确了解小部件,我们需要查看网页的组件。

website component

As you can see in the image, a webpage is divided into four main areas: header, content, sidebar and footer. The header usually consists of an image and a menu and is created using your theme’s options or customisation controls. The content is usually a post or page, though it can also be a range of other content such as an image gallery, product, portfolio or custom content. The sidebar and footer are for displaying a wide range of additional content on your website and this is created and put into a structure using widgets.

如您在图像中看到的,网页分为四个主要区域:页眉,内容,侧边栏和页脚。 标题通常由图像和菜单组成,并使用主题的选项或自定义控件创建。 内容通常是帖子或页面,尽管它也可以是一系列其他内容,例如图库,产品,产品组合或自定义内容。 边栏和页脚用于在您的网站上显示各种其他内容,这些内容是使用小部件创建并放入结构中的。

什么是小部件? (What are Widgets?)

Widget are tools for displaying small pieces of content in your sidebar or footer. There are many types of widget, each with their own function, letting you display a specific type of content and giving you some control over how that content is displayed.

窗口小部件是用于在侧边栏或页脚中显示少量内容的工具。 窗口小部件有很多类型,每种都有各自的功能,可以让您显示特定类型的内容,并可以控制这些内容的显示方式。

You can display a range of different widgets at the same time and have the ability to order the content in the way that best suits your website.

您可以同时显示一系列不同的小部件,并能够以最适合您的网站的方式订购内容。

在哪里可以找到要使用的小部件? (Where do I find widgets to use?)

To find the widgets available to use on your website, navigate to ‘Appearance’ then ‘Widgets’ in your WordPress admin panel.

要查找可在您的网站上使用的小部件,请导航至WordPress管理面板中的“外观”,然后导航至“小部件”。

wp21 1

The widgets you can use can be found on the left-hand side of the page, under the heading Available Widgets.  Widget availability depends on a number of factors. WordPress comes pre-installed with a number of widgets and themes often have their own additional widgets too. You can also install plugins which create other widgets and you can even create your own.

您可以使用的小部件可在页面左侧的“可用小部件”标题下找到。 窗口小部件的可用性取决于许多因素。 WordPress预装了许多小部件,主题通常也具有自己的其他小部件。 您还可以安装创建其他小部件的插件,甚至可以创建自己的插件。

如何添加小部件? (How do I add a widget?)

Adding a widget is unbelievably easy. Either, drag and drop the widget you want to use into the widget area you want it to go (e.g. Primary Sidebar or Footer 1) or click on the widget and select widget area from the dropdown list as in the image below.

添加小部件非常简单。 可以将要使用的窗口小部件拖放到希望其进入的窗口小部件区域中(例如,主边栏或页脚1),或者单击窗口小部件并从下拉列表中选择窗口小部件区域,如下图所示。

wp21 2

All you need to do then is adjust the settings to your preference and click on save. You can see this in operation in the image below, where we’ve used a Text widget to add some sample text to our sidebar.

然后,您所需要做的就是根据自己的喜好调整设置,然后单击“保存”。 您可以在下图中的操作中看到这一点,其中我们使用了文本小部件将一些示例文本添加到了侧边栏中。

primary sidebar

The sidebar on our website now looks like this:

我们网站上的侧边栏现在如下所示:

sidebar on website

Putting widgets in the footer is just as simple.  Here we’ve put a ‘Contact Info’ widget in Footer 1, a ‘Subscribe’ widget in Footer 2 and a ‘Search This Site’ widget in Footer 3. The final result looks like this:

将小部件放在页脚中同样简单。 在这里,我们在页脚1中放置了“联系信息”小部件,在页脚2中放置了“订阅”小部件,在页脚3中放置了“搜索此站点”小部件,最终结果如下所示:

widget on website

我添加了一个小部件,但是如何删除它? (I’ve added a widget, but how do I remove it?)

Removing a widget is just as easy as adding one.

删除小部件就像添加一个小部件一样容易。

  • Return to the Widgets page (under Appearance) in the WordPress admin panel.

    返回WordPress管理面板中的“小部件”页面(在外观下)。
  • Find the sidebar or footer area that you want to delete your widget from.

    找到要从中删除小部件的侧边栏或页脚区域。
  • Click on the widget you want to delete so that the settings box opens.

    单击要删除的小部件,以打开设置框。
  • Click ‘Delete’ at the bottom. The widget will now disappear. See image below.

    点击底部的“删除”。 小部件现在将消失。 参见下图。

footer widget

There are, however, two alternative options which you may want to consider. If you want to move the widget to a different widget area you don’t need to delete and start again – instead just drag the widget to the new area you want it to go to and it will appear there automatically.

但是,您可能要考虑两个替代选项。 如果要将小部件移动到其他小部件区域,则无需删除并重新开始–只需将小部件拖动到希望其进入的新区域,它将自动出现在该区域。

Alternatively, if you think you may want to use it at a later time, just drag the widget out of the widget area and drop it at the bottom of the Available Widgets page under the Inactive Widgets heading. Any setting you saved will be stored here.

或者,如果您认为以后可能要使用它,只需将窗口小部件拖出窗口小部件区域,然后将其放在“不活动窗口小部件”标题下“可用窗口小部件”页面的底部即可。 您保存的所有设置都将存储在此处。

inactive widgets

如何在侧边栏或页脚中组织小部件的顺序 (How to organise the order of widgets in a sidebar or footer)

In a sidebar, you organise simply by dragging and dropping. If you want to rearrange, just click on the widget you want to move and drag it above, below or between the others.

在边栏中,您只需拖放即可进行组织。 如果要重新排列,只需单击要移动的小部件,然后将其拖动到其他部件的上方,下方或之间即可。

In the footer, there are usually four sections, each taking up a quarter of the page. Footer 1 is usually on the left and the numbers go in order to Footer 4 on the right. Just drag your widget to the most appropriate one.

在页脚中通常有四个部分,每个部分占页面的四分之一。 页脚1通常在左侧,数字按顺序移至页脚4在右侧。 只需将您的小部件拖动到最合适的小部件即可。

小部件需要注意的问题 (Issues that you need to be aware of with widgets)

Whilst widgets offer great functionality to a website there are some issues which you need to consider.

尽管窗口小部件为网站提供了强大的功能,但您仍需要考虑一些问题。

Adding too many widgets may slow your website down as each individual widget will require extra data to be sent to your reader’s browser. Only use those which are needed or valuable for your site.

添加过多的小部件可能会使您的网站速度变慢,因为每个小部件都需要将额外的数据发送到阅读器的浏览器。 仅使用对您的网站有用或有价值的内容。

Sidebars and footers come in fixed widths, depending upon the design of your site. Sometimes it is possible to put images or videos in a widget which are too big for your sidebar / footer and which the widget has difficulty resizing. This can result in either squashed images, sidebars which overlap into the main content or webpages that need to scroll sideways to be fully viewed. All of these should be avoided. To fix this, you may need a different widget or need to tweak the image or video embed code. This issue can also be caused by adding advertising code in a widget, so if you use Adwords or show affiliate marketing banners served from another website, do be aware.

边栏和页脚的宽度固定,具体取决于您网站的设计。 有时,可能会将图像或视频放在窗口小部件中,而对于您的侧边栏/页脚而言太大,并且窗口小部件难以调整大小。 这可能会导致图像压缩,重叠到主要内容中的侧边栏或需要横向滚动才能完全查看的网页。 所有这些都应避免。 要解决此问题,您可能需要其他控件或需要调整图像或视频嵌入代码。 此问题也可能是由于在小部件中添加广告代码引起的,因此,如果您使用Adwords或显示从另一个网站提供的会员营销横幅,请注意。

Whilst sidebars and footers have fixed widths, they don’t have a fixed height. If you add too many widgets in a sidebar your page can look very odd; the sidebar keeps going on and on after the content has finished. Ideally, the content of your sidebar should not be longer than the content of your post or page.  With footers, this can look even worse. A footer should be short – 300px deep maximum. Always restrict to one widget per footer section and keep the content short in the widget’s settings

虽然侧边栏和页脚具有固定的宽度,但它们没有固定的高度。 如果您在侧边栏中添加了太多的小部件,则页面可能看起来很奇怪。 内容完成后,侧边栏会不断打开。 理想情况下,边栏的内容不应长于帖子或页面的内容。 如果使用页脚,情况可能会更糟。 页脚应简短-最多300px深。 始终在每个页脚节中限制一个小部件,并在小部件的设置中保持内容简短

The other thing you should always check is how your sidebar and footer displays on mobiles and tablets. Responsive themes usually work well, but occasionally some of them can display sidebars and footers in ways which look a little odd on mobile devices.

您应该经常检查的另一件事是侧边栏和页脚在手机和平​​板电脑上的显示方式。 自适应主题通常效果很好,但有时其中一些主题可以以在移动设备上看起来有些奇怪的方式显示侧边栏和页脚。

寻找小部件灵活性? (Looking for widget flexibility?)

If you want to take your widget use one stage further, then one of the best things you can do is have different widgets showing on different pages or categories. This way you can match the content of your sidebar to the needs of people who visit different sections of your website. This can be achieved by using plugins such as Content Aware Sidebars.

如果您想让窗口小部件使用一个阶段,那么您可以做的最好的事情之一就是在不同的页面或类别上显示不同的窗口小部件。 这样,您可以将侧边栏的内容与访问网站不同部分的人员的需求进行匹配。 这可以通过使用诸如Content Aware Sidebars之类的插件来实现。

结论 (Conclusion)

You should now have a clearer understanding of what widgets are, where on a web page you can place them and how to put them there and remove them. In addition, you should have a better grasp of their benefits and some of the issues they can cause.

现在,您应该对小部件是什么,可以在网页上放置的位置以及如何将其放置和删除它们有更清晰的了解。 此外,您应该更好地了解它们的好处以及它们可能引起的一些问题。

If you are looking for WordPress hosting, check out our Dedicated WordPress Hosting page. Our affordable packages are packed with helpful features and backed up with expert WordPress support and first-class security.

如果您正在寻找WordPress托管,请查看我们的WordPress专用托管页面。 我们负担得起的软件包包含有用的功能,并以WordPress专业支持和一流的安全性为后盾。

翻译自: https://www.eukhost.com/blog/webhosting/wordpress-widgets-what-are-they-and-how-do-i-use-them/

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值