【发布时间】:2018-12-08 04:04:24
【问题描述】:
我正在使用 get_posts 的 include 选项,并且 numberposts 并不限制我现在设置的帖子数量,即 1,它只是加载所有设置的包含 ID。不能限制包含帖子ID的数量吗?这是我的代码。
$image_list = get_posts(array(
'numberposts' => 1,
'include' => '559,117,129',
'post_type' => 'ft_gallery',
));
【问题讨论】:
-
能否请您在此处运行此代码并复制结果查询以确保您传递给函数的内容?
$getpost_attr['post_type'] = 'ft_gallery'; $getpost_attr['include'] = $this->albums_gallery_list_of_ids($image_list_check); $getpost_attr['posts_per_page'] = esc_html( $post_count ); $getpost_attr['orderby'] = esc_html( $orderby ); $getpost_attr['order'] = esc_html( $order ); $getpost_attr['paged'] = esc_html( $paged ); print_r($getpost_attr);抱歉格式化,评论不允许我换行。 -
我添加了返回数组
-
只需使用 wp_reset_postdata();在foreach之后
-
@MounerMostafa 我不认为这有什么不同。看起来像 wp_reset_postdata();适用于 WP_Query 但我使用的是 get_posts。如果您可以在答案中展示更详细的解决方法,那就太棒了。
-
@amedv,抱歉,这是您请求数组的返回值([post_type] => ft_gallery [include] => 559,117,129,496,797 [posts_per_page] => 3 [orderby] => menu_order [order] => asc [分页] => 1)
标签: php wordpress pagination