php - get_posts 的包含选项有效,但不限制帖子数量
问题描述
我正在使用 get_posts 的 include 选项,并且 numberposts 并不限制我现在设置的帖子数量,即 1,它只是加载所有设置的包含 ID。不能限制包含帖子ID的数量吗?这是我的代码。
$image_list = get_posts(array(
'numberposts' => 1,
'include' => '559,117,129',
'post_type' => 'ft_gallery',
));
解决方案
所以解决方案是使用 post__in 并确保数字列表是数组格式。感谢一切努力。
$image_list = get_posts(array(
'numberposts' => 1,
'post__in' => array([0] => 559 [1] => 117 [2] => 129 [3] => 496 [4] => 797),
'post_type' => 'ft_gallery',
));
推荐阅读
- elasticsearch - KIBANA 和 ELASTICSEARCH 配置 CA
- html - 响应式进度条垂直对齐
- chef-infra - 如何在测试厨房的节点上启用特定的 Ohai 插件
- mysql - 检查日期可用性的子查询
- c++ - 使用 Conan 直接从 GitHub 安装包
- omnet++ - 如何将 'const omnetpp::SimTime' 转换为 'double'
- dialogflow-es - 在荷兰测试 Actions on Google Transaction API 时出现“抱歉,我无法在您所在地区收款”消息
- aurelia - 在转发器中使用 @computedFrom 数组
- r - 具有灵活函数参数的复杂 if else 函数的代码改进
- c# - .NET Framework 依赖树