admin管理员组文章数量:1125758
I have a custom wordpress query like so:
$query = new WP_Query(array(
'post_status' => 'future || publish',
'post_type' => 'kalender',
'order' => 'ASC'
));
But the problem is that the items shown on the pages also include the items that are in the trash? I don't understand why because according to the post_status
only published & future posts should be shown?
The item in the trash is a post in the future though? Maybe that's why it's shown but how can I exclude that one?
I have a custom wordpress query like so:
$query = new WP_Query(array(
'post_status' => 'future || publish',
'post_type' => 'kalender',
'order' => 'ASC'
));
But the problem is that the items shown on the pages also include the items that are in the trash? I don't understand why because according to the post_status
only published & future posts should be shown?
The item in the trash is a post in the future though? Maybe that's why it's shown but how can I exclude that one?
Share Improve this question edited May 30, 2019 at 21:04 alo Malbarez 4451 gold badge6 silver badges7 bronze badges asked Mar 27, 2013 at 17:17 user2019515user2019515 4666 silver badges17 bronze badges 2- 2 I assume you're trying to create an event calendar of sorts by using the publish date as the event date. if that's the case, you're better off storing the event date as post meta data rather than abusing the publish date for this purpose. – Milo Commented Mar 27, 2013 at 17:22
- @Milo Thank you for your suggestion, I understand your reasoning, I'll change it soon! – user2019515 Commented Mar 27, 2013 at 17:26
1 Answer
Reset to default 5The syntax in the query above is wrong, it should be:
$query = new WP_Query(array(
'post_status' => array( 'publish', 'future' ),
'post_type' => 'kalender',
'order' => 'ASC'
));
That seems to solve the problem. :)
本文标签: Custom query shows custom post types in trash
版权声明:本文标题:Custom query shows custom post types in trash 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736673886a1947072.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论