wordpress列数布局_如何在WordPress中列出未来即将发布的预定帖子

wordpress列数布局

Recently, one of our users asked us how they can list scheduled or future upcoming posts in WordPress. Showing upcoming posts can be helpful in getting people to subscribe to your blog. In this article, we will show you how to display future upcoming posts in WordPress sidebar.

最近,我们的一位用户问我们如何在WordPress中列出预定的或将来的帖子。 显示即将发布的帖子有助于使人们订阅您的博客。 在本文中,我们将向您展示如何在WordPress侧边栏中显示将来的帖子。

Show scheduled and future upcoming posts
WordPress中计划或将来要发布的帖子是什么? (What is Scheduled or Future Upcoming Posts in WordPress?)

If you have been blogging for a while, then you have probably noticed that publishing posts on a certain time gets more people to read it. If you are new to blogging and don’t know what time you get the most visitors, then you should start using Google Analytics to track this information.

如果您已经写了一段时间的博客,那么您可能已经注意到,在特定时间发布帖子会使更多的人阅读它。 如果您不熟悉博客,并且不知道什么时候获得最多的访问者,则应该开始使用Google Analytics(分析)来跟踪此信息。

The problem is that you cannot just sit around and wait for that time to hit the publish button. That’s why WordPress comes with built-in scheduling feature. It allows you to schedule your posts to be published later.

问题在于,您不能只是闲坐一会儿并等待该时间来点击“发布”按钮。 这就是WordPress带有内置计划功能的原因。 它使您可以安排您的帖子稍后发布。

Using scheduling you can focus on creating content and managing your editorial calendar like a pro.

使用计划,您可以专注于创建内容和像专业人士一样管理编辑日历

Having said that, let’s see how you can show off your upcoming posts in WordPress and use it to get more subscribers.

话虽如此,让我们看看如何在WordPress中炫耀即将发布的帖子并使用它来吸引更多订阅者。

To make it easy, we have created a video tutorial on how to list future upcoming scheduled posts that you can watch below.

为简单起见,我们创建了一个视频教程,介绍如何列出将来即将发布的预定帖子,您可以在下面观看。

演示地址

However if you just want to follow text-instructions, then you can follow our step by step tutorial on how to list future upcoming scheduled posts in WordPress.

但是,如果您只想按照文本说明进行操作,则可以按照我们的分步教程进行操作,以了解如何在WordPress中列出将来即将发布的预定帖子。

方法1:显示带有插件的预定或将来的帖子 (Method 1: Showing Scheduled or Future Posts with Plugin)

First thing you need to do is install and activate SOUP – Show off Upcoming Posts plugin. For more details, see our step by step guide on how to install a WordPress plugin.

您需要做的第一件事是安装并激活SOUP –炫耀即将发布的帖子插件。 有关更多详细信息,请参阅有关如何安装WordPress插件的分步指南。

Upon activation, you need to visit Appearance » Widgets page. There you will find ‘Upcoming Posts’ widget under the list of available widgets. Simply add the widget to your sidebar where you to display scheduled posts.

激活后,您需要访问外观»小部件页面。 在此处,您可以在可用小部件列表下找到“即将发布的帖子”小部件。 只需将小部件添加到侧边栏即可显示预定的帖子。

Upcoming posts widget

The widget settings allow you to choose the number of scheduled posts you want to show. You can also show dates next to them, link to your RSS feed, or link to a page where users can signup for your email list.

小部件设置允许您选择要显示的预定帖子的数量。 您还可以在日期旁边显示日期,链接到RSS feed或链接到用户可以在其中注册您的电子邮件列表的页面

Click on the save button to store your widget settings.

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

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

现在,您可以访问您的网站以查看正在运行的小部件。

Preview of upcoming posts in sidebar
方法2:手动显示预定或即将发布的帖子 (Method 2: Showing Scheduled or Upcoming Posts Manually)

Simply add this code to your theme’s functions.php file or a site-specific plugin.

只需将此代码添加到主题的functions.php文件或特定站点的插件中即可



function wpb_upcoming_posts() { 
	// The query to fetch future posts
	$the_query = new WP_Query(array( 
		'post_status' => 'future',
		'posts_per_page' => 3,
		'orderby' => 'date',
		'order' => 'ASC'
	));

// The loop to display posts
if ( $the_query->have_posts() ) {
	echo '<ul>';
	while ( $the_query->have_posts() ) {
		$the_query->the_post();
		$output .= '<li>' . get_the_title() .' ('.  get_the_time('d-M-Y') . ')</li>';
	}
	echo '</ul>';

} else {
	// Show this when no future posts are found
	$output .= '<p>No posts planned yet.</p>';
}

// Reset post data
wp_reset_postdata();

// Return output

return $output; 
} 
// Add shortcode
add_shortcode('upcoming_posts', 'wpb_upcoming_posts'); 
// Enable shortcode execution inside text widgets
add_filter('widget_text', 'do_shortcode');


Now you can visit Appearance » Widgets page. Add a text widget to your sidebar where you want to display upcoming posts and add this shortcode inside the widget.

现在您可以访问外观»小部件页面。 在您要显示即将发布的帖子的边栏中添加一个文本小部件,并将此短代码添加到小部件中。

[upcoming_posts]

[upcoming_posts]

Adding upcoming posts shortcode in a text widget

Click on the save button to store your widget settings.

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

You can now visit your website to see the upcoming scheduled posts in your sidebar. You can also use this shortcode in a post, page, or a template in your child theme.

现在,您可以访问您的网站,在侧边栏中查看即将发布的预定帖子。 您也可以在子主题的帖子,页面或模板中使用此短代码。

We hope this article helped you learn how to show scheduled posts in your WordPress sidebar. You may also want to see our list of these 25 most useful WordPress widgets for your site.

我们希望本文能帮助您学习如何在WordPress侧边栏中显示预定的帖子。 您可能还想查看我们的25个对您的站点最有用的WordPress小部件的列表。

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-list-future-upcoming-posts-in-wordpress/

wordpress列数布局

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值