Wordpress:将过滤器添加到query_posts中,只显示带有“date”的帖子设定为今天或将来 [英] Wordpress: Add filter to query_posts to only show posts with "date" set to today or future

查看:141
本文介绍了Wordpress:将过滤器添加到query_posts中,只显示带有“date”的帖子设定为今天或将来的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用此查询来显示我的帖子:

I am using this query to display my posts:

$today = getdate();
$year=$today["year"];
$month=$today["mon"];
$day=$today["mday"];

query_posts( $query_string.'order=ASC' . '&post.status=future,publish'.'&year='.$year.'&monthnum='.$month );
?>

现在,我想添加一个过滤器,只显示已发布的帖子,或将发布在未来。

Now I want to add a filter to only show posts that have been published TODAY or will be published in the future.

示例:今天是3月22日。 PostA于3月1日发布,PostB已于今天公布,PostC将于3月24日公布(状态未来已经在我的询问中,但仍将显示)。
我的新查询过滤器只能显示PostB和PostC。

Example: Today is the 22nd of March. PostA was published on the 1st of March, PostB has been published today and PostC will be published (status 'future' is already in my query, so it nevertheless will be displayed) on the 24th of March. My new filter for the query should only display PostB and PostC.

非常感谢!

: - )

推荐答案

尝试这个:

$archive_year  = get_the_time('Y'); $archive_month = get_the_time('m'); $archive_day   = get_the_time('d'); query_posts('year=' .$archive_year .'&monthnum=' .$archive_month .'&day=' .$archive_day);

这篇关于Wordpress:将过滤器添加到query_posts中,只显示带有“date”的帖子设定为今天或将来的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆