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

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 谷歌分析 to track this information.
如果您已经写了一段时间的博客,那么您可能已经注意到,在特定时间发布帖子会使更多的人阅读它。 如果您不熟悉博客,并且不知道什么时候获得最多的访问者,则应该开始使用谷歌分析来跟踪此信息。
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 安排你的帖子 to be published later.
问题在于,您不能只是闲坐一会儿并等待该时间来点击“发布”按钮。 这就是WordPress带有内置计划功能的原因。 它使您可以安排您的帖子稍后发布。
Using scheduling you can focus on creating content and 管理您的编辑日历 like a pro.
使用计划,您可以专注于创建内容和像专业人士一样管理编辑日历 。
话虽如此,让我们看看如何在 WordPress 中展示即将发布的帖子并使用它来吸引更多订阅者。
话虽如此,让我们看看如何在 WordPress 中展示即将发布的帖子并使用它来吸引更多订阅者。
为了方便起见,我们创建了一个视频教程,介绍如何列出未来即将发布的预定帖子,您可以在下面观看。
为了简单起见,我们创建了一个视频教程,介绍如何列出未来即将发布的预定帖子,您可以在下面观看。
但是,如果您只想遵循文本说明,那么您可以按照我们的分步教程了解如何在 WordPress 中列出未来即将发布的预定帖子。
但是,如果您只想遵循文本说明,则可以按照我们的分步教程了解如何在 WordPress 中列出未来计划的帖子。
方法1:显示带有插件的预定或将来的帖子 (Method 1: Showing Scheduled or Future Posts with Plugin)
First thing you need to do is install and activate SOUP – 展示即将发布的帖子 plugin. For more details, see our step by step guide on 如何安装 WordPress 插件.
您需要做的第一件事是安装并激活SOUP – 展示即将发布的帖子插件。 有关更多详细信息,请参阅有关如何安装 WordPress 插件步指南。
Upon activation, you need to visit 外观 » 小部件 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.
激活后,您需要访问外观 » 小部件页面。 在此处,您可以在可用小部件列表下找到“即将发布的帖子”小部件。 只需将小部件添加到侧边栏即可显示预定的帖子。

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订阅, or link to a page where users can signup for your 电子邮件列表.
小部件设置允许您选择要显示的预定帖子的数量。 您还可以在日期旁边显示日期,链接到RSS订阅或链接到用户可以在其中注册您的电子邮件列表页面 。
单击保存按钮来存储您的小部件设置。
单击“保存”按钮来存储小部件设置。
您现在可以访问您的网站以查看正在运行的小部件。
现在您可以访问您的网站以查看正在运行的小部件。

方法2:手动显示预定或即将发布的帖子 (Method 2: Showing Scheduled or Upcoming Posts Manually)
Simply add this code to your theme’s 函数.php file or a 特定于站点的插件.
只需将此代码添加到主题的函数.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 外观 » 小部件 page. Add a text widget to your sidebar where you want to display upcoming posts and add this 短代码 inside the widget.
现在您可以访问外观 » 小部件页面。 在您要显示即将发布的帖子的边栏中添加一个文本小部件,并将此短代码添加到小部件中。
[upcoming_posts]
[upcoming_posts]

单击保存按钮来存储您的小部件设置。
单击“保存”按钮来存储小部件设置。
您现在可以访问您的网站,在侧边栏中查看即将发布的预定帖子。您还可以在子主题的帖子、页面或模板中使用此短代码。
您现在可以访问您的网站并在侧边栏中查看即将发布的预定帖子。您还可以在子主题的帖子、页面或模板中使用此短代码。
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 个最适合您网站的 WordPress 小部件.
我们希望本文能帮助您学习如何在WordPress侧边栏中显示预定的帖子。 您可能还想查看我们的25 个对您的网站最有用的 WordPress 小部件列表。
If you liked this article, then please subscribe to our YouTube 频道 for WordPress video tutorials. You can also find us on 推特 and Facebook.
如果您喜欢这篇文章,请订阅我们的YouTube 频道 WordPress视频教程。 您也可以在推特和Facebook上找到我们。
翻译自: https://www.wpbeginner.com/wp-tutorials/how-to-list-future-upcoming-posts-in-wordpress/
WordPress 列布局