wordpress侧边栏_如何在WordPress侧边栏中添加特色帖子

wordpress侧边栏

Do you want to add a featured posts section in the sidebar of your WordPress website?

您是否要在WordPress网站的侧边栏中添加特色帖子部分?

Displaying your top content as featured posts in the sidebar can help you drive more traffic to your pillar articles.

在边栏中将您的主要内容显示为特色文章,可以帮助您吸引更多访问量。

In this article, we’ll show you how to easily display featured posts in WordPress sidebar using multiple methods.

在本文中,我们将向您展示如何使用多种方法在WordPress边栏中轻松显示特色帖子。

Easily feature posts in WordPress sidebar

为什么要在WordPress侧边栏中添加特色帖子? (Why Add Featured Posts in WordPress Sidebar?)

Sidebars are the non-content area of your website. Most users utilize this space by adding a email newsletter form, social media buttons, and / or displaying banner ads.

侧栏是您网站的非内容区域。 大多数用户通过添加电子邮件通讯表单 ,社交媒体按钮和/或显示横幅广告来利用此空间。

Another way you can utilize the sidebar is by displaying your top articles as featured posts. This helps you get more traffic to those articles, and you users are able to discover your best content without looking for it.

利用侧边栏的另一种方法是将热门文章显示为特色文章。 这可以帮助您吸引更多访问这些文章的流量 ,并且用户无需寻找就可以发现自己的最佳内容。

Here is how we feature our top articles on WPBeginner. This sidebar widget appears on all pages of our website.

这是我们在WPBeginner上精选文章的方式。 此侧边栏小部件将出现在我们网站的所有页面上。

Featured posts WPBeginner

That being said, let’s take a look at how to add featured posts in WordPress sidebar to boost your pageviews and user engagement.

话虽如此,让我们看一下如何在WordPress侧边栏中添加特色帖子,以提高您的综合浏览量和用户参与度。

方法1.在WordPress侧边栏中添加帖子 (Method 1. Featuring Posts in WordPress Sidebar)

This method is pretty straight forward and does not require you to install any plugin on your website.

这种方法非常简单,不需要您在网站上安装任何插件。

Simply go to Appearance » Widgets page and add a Text widget to your WordPress sidebar.

只需转到外观»小部件页面,然后将文本小部件添加到WordPress边栏中。

Featuring posts in WordPress sidebar using a text widget

This widget comes with a visual editor equipped with a few formatting buttons at the top. You can simply add titles of the posts you want to feature as a bulleted list or plain text.

该小部件带有一个视觉编辑器,该编辑器的顶部配有一些格式化按钮。 您可以简单地添加要作为项目符号列表或纯文本显示的帖子标题。

After that, select the post title and then click on the link button to add link to the blog post.

之后,选择帖子标题,然后单击链接按钮以将链接添加到博客帖子。

Once you are done, don’t forget to click on the ‘Save’ button to store your changes.

完成后,请不要忘记单击“保存”按钮来存储您的更改。

You can now visit your website to see your featured posts in action. This is how it looked on our demo site.

现在,您可以访问您的网站以查看您的精选帖子。 这就是在我们的演示站点上的外观。

Featured posts in WordPress sidebar text widget

方法2.使用菜单在WordPress边栏中的功能发布 (Method 2. Feature Posts in WordPress Sidebar using Menus)

This method is a little indirect but gives you the ability to manage your featured posts more effectively.

这种方法有点间接,但是使您能够更有效地管理特色帖子。

Instead of adding the featured post list in a Text widget, we will create a navigation menu and then display it in the sidebar.

我们将创建一个导航菜单 ,然后将其显示在边栏中,而不是在“文本”小部件中添加精选的帖子列表。

The advantage of this method is that you can easily add new posts without editing the widget, and you can reorganize the list with a drag & drop interface.

这种方法的优点是您可以轻松地添加新帖子而无需编辑小部件,并且可以使用拖放界面重新组织列表。

First, you need to visit the Appearance » Menus page and click on the ‘create a new menu’ link.

首先,您需要访问外观»菜单页面,然后单击“创建新菜单”链接。

Create a new custom menu in WordPress

Next, you need to enter a name for your menu that helps you easily identify it whenever you need to add it somewhere. After that click on the ‘Create Menu’ button to continue.

接下来,您需要为菜单输入一个名称,该名称可以帮助您在需要添加菜单时轻松地进行识别。 之后,单击“创建菜单”按钮继续。

Enter your new menu name

WordPress will now create a new blank menu for you.

WordPress现在将为您创建一个新的空白菜单。

Now, you need to click on the ‘Posts’ tab from the left column to expand it. From here you need to select the posts you want to feature. You can find them under Recent, All, or use the search option to locate and select them.

现在,您需要单击左栏中的“帖子”标签以将其展开。 在这里,您需要选择要发布的帖子。 您可以在“最近的”,“全部”下找到它们,或使用搜索选项找到并选择它们。

Select posts you want to feature

After selecting the posts you want to add, click on the ‘Add to Menu’ button. Your posts will now appear in the right column and you can edit each one of their titles by clicking on it. You can also rearrange them by simply dragging them up or down.

选择要添加的帖子后,单击“添加到菜单”按钮。 您的帖子现在将显示在右栏中,您可以通过单击它们来编辑它们的标题。 您也可以通过简单地上下拖动来重新排列它们。

Save your menu

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

满意后,单击“保存菜单”按钮以存储您的更改。

Your menu is now ready to be used.

现在可以使用菜单了。

Adding Featured Posts Menu in Sidebar

在侧边栏中添加特色帖子菜单

Simply go to the Appearance » Widgets page and add the ‘Navigation Menu’ widget to your sidebar.

只需转到外观»小部件页面,然后将“导航菜单”小部件添加到侧边栏中。

Add Navigation Menu widget to your sidebar

Next, you need to provide a title for your sidebar menu widget and then select the featured posts menu you created earlier from the dropdown menu.

接下来,您需要为侧边栏菜单小部件提供标题,然后从下拉菜单中选择您之前创建的精选文章菜单。

Don’t forget to click on the Save button to store your widget settings. You can now visit your website to see your featured posts list in action.

不要忘记单击“保存”按钮来存储小部件设置。 现在,您可以访问您的网站以查看特色帖子列表。

Featured posts displayed using navigation menu widget

方法3.使用古腾堡在WordPress中添加特色帖子 (Method 3. Adding Featured Posts in WordPress Using Gutenberg)

A lot of users may want to display their feature posts inside a WordPress post or page. They may be using the page editor to create layouts for their homepage or their theme may not have a sidebar.

很多用户可能希望在WordPress帖子或页面内显示其功能文章。 他们可能正在使用页面编辑器为其主页创建布局,或者其主题可能没有侧边栏。

This method allows you to feature posts in your WordPress posts and pages.

这种方法使您可以在WordPress帖子和页面中添加帖子

Simply edit a WordPress post or page where you want to showcase your featured posts. On the post edit screen, click on the add new block button (+) at the top and then add the ‘List’ block to your content area.

只需在要显示特色帖子的WordPress帖子或页面上进行编辑即可。 在帖子编辑屏幕上,单击顶部的添加新块按钮(+),然后将“列表”块添加到您的内容区域。

Add list block

Simply add the title of each blog post you want to feature as an item on the list. Then select the text and click on the link button in the toolbar to create a link to the article.

只需在列表中添加每个要发布的博客文章的标题即可。 然后选择文本,然后单击工具栏中的链接按钮以创建文章的链接

Once you are done, you can save your changes and update or publish the post. This is how it looked on our demo website.

完成后,您可以保存更改并更新或发布帖子。 这就是我们的演示网站上的样子。

Reuse The Feature Posts Block

重用功能帖子块

One great feature of the block editor is that you can save block as ‘Reusable block’ and then add the same block in any posts or pages you want.

块编辑器的一大功能是,您可以将块另存为“可重用的块”,然后在所需的任何帖子或页面中添加相同的块。

To make your feature posts block reusable, simply click on the three-dot menu icon in the block toolbar and select ‘Add to reusable blocks’.

要使您的要素发布块可重复使用,只需单击块工具栏中的三点菜单图标,然后选择“添加到可重复使用的块”。

Create reusable block

Next, you’ll be asked to provide a name for your reusable block. Give it a name that helps you easily identify it later.

接下来,将要求您提供可重复使用块的名称。 为其命名,以帮助您以后轻松识别它。

Name your reusable block

Click on the Save button to save your reusable block.

单击保存按钮以保存可重复使用的块。

Now, whenever you are editing a post or page where you want to display the feature posts again. Simply click on the add new block button and look for your reusable block by typing its name.

现在,每当您要编辑帖子或页面时,您都希望再次显示功能文章。 只需单击添加新块按钮,然后通过键入其名称来查找可重复使用的块。

Adding reusable block

You can also edit reusable blocks and it will automatically get updated everywhere. For more details, see our article on how to add reusable blocks in WordPress.

您还可以编辑可重复使用的块,它将在任何地方自动进行更新。 有关更多详细信息,请参阅有关如何在WordPress中添加可重用块的文章。

方法4:用缩略图在WordPress中显示特色帖子 (Method 4. Display Featured Posts in WordPress with Thumbnails)

A simple plain list of links may often go by unnoticed by your users. Displaying thumbnails with your featured posts would help users notice them more easily.

一个简单的普通链接列表可能经常会被用户忽略。 显示带有特色帖子的缩略图可帮助用户更轻松地注意到它们。

To do that, we’ll be using a plugin to fetch and display a list of our featured posts along with thumbnails.

为此,我们将使用插件来获取并显示精选文章列表以及缩略图。

First, you need to install and activate the Display Posts plugin. For more details, see our step by step guide on how to install a WordPress plugin.

首先,您需要安装并激活Display Posts插件。 有关更多详细信息,请参阅有关如何安装WordPress插件的分步指南。

This plugin allows you to select and display any WordPress posts you want anywhere on your website. It uses shortcodes and allows you to build a custom query using a variety of parameters.

这个插件可以让您选择并显示您想要在网站上的任何WordPress帖子。 它使用简码,并允许您使用各种参数来构建自定义查询

For instance, we’ll be using it to fetch and display the list of your featured posts along with thumbnail and excerpt.

例如,我们将使用它来获取并显示您的特色文章列表以及缩略图和摘录。

Head over to Appearance » Widgets page and add a ‘Text’ widget to your sidebar. In the text area of the widget, simply add the following shortcode.

转到外观»小部件页面,然后将“文本”小部件添加到侧边栏中。 在窗口小部件的文本区域中,只需添加以下短代码。


[display-posts id="1,1178,1177,1176,1174,1173,1016,1011," image_size="thumbnail" include_excerpt="true" excerpt_length="10"]

Don’t forget to replace the id values to match the IDs of posts that you want to feature.

不要忘记替换id值以匹配要显示的帖子的ID。

Tip: See our article on how to locate the post IDs in WordPress.

提示:请参阅有关如何在WordPress中找到帖子ID的文章

Now click on the ‘Save’ button to store your widget settings.

现在,单击“保存”按钮以存储您的小部件设置。

You can now visit your website to see it in action. It may not look good out of the box so let’s add some CSS magic to clean it up a little.

现在,您可以访问您的网站以查看其运行情况。 开箱即用的效果可能不太好,所以让我们添加一些CSS魔术来对其进行清理。

Go to the Appearance » Customize page to launch theme customizer. From here click on the Additional CSS tab and you will see a box where you can add your custom CSS.

转到外观»定制页面以启动主题定制器。 从此处单击“其他CSS”选项卡,您将看到一个框,您可以在其中添加自定义CSS。

Custom CSS box

You can now copy and paste the following CSS to the custom CSS box on your website.

现在,您可以将以下CSS复制并粘贴到网站上的自定义CSS框中。


ul.display-posts-listing img { 
max-height:50px;
max-width:50px; 
float:left;
padding-right:4px;
}
ul.display-posts-listing li { 
margin-bottom:20px;
font-size:11px;
display:inline-block; 
}

You’ll see live preview of your changes applied on your WordPress blog. Feel free to modify the CSS to meet your requirements.

您将在WordPress博客上看到所做更改的实时预览。 随意修改CSS以满足您的要求。

Once you are done, don’t forget to click on the Publish button at the top to store your custom CSS.

完成后,不要忘记单击顶部的“发布”按钮来存储您的自定义CSS。

You can now visit your website to see your featured posts with thumbnail and excerpt.

现在,您可以访问您的网站,以查看带有缩略图和摘录的特色帖子。

Featured posts with thumbnail and excerpt

We hope this article helped you learn how to easily feature posts in WordPress sidebar. You may also want to see our guide on the best email marketing services and best WordPress SEO plugins to grow your website traffic.

我们希望本文能帮助您学习如何轻松地在WordPress侧边栏中添加帖子。 您可能还想查看有关最佳电子邮件营销服务最佳WordPress SEO插件的指南,以增加您的网站流量。

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/beginners-guide/how-to-add-featured-posts-in-wordpress-sidebar/

wordpress侧边栏

  • 0
    点赞
  • 0
    评论
  • 0
    收藏
  • 一键三连
    一键三连
  • 扫一扫,分享海报

表情包
插入表情
评论将由博主筛选后显示,对所有人可见 | 还能输入1000个字符
©️2021 CSDN 皮肤主题: 编程工作室 设计师:CSDN官方博客 返回首页
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值