【发布时间】:2022-01-21 13:06:41
【问题描述】:
我怎样才能像这样在post__not_in 中放入两个变量:
'post__not_in' => $excludeHome, $excludePostSlide
当我这样做时,只有来自第一个变量的帖子不会从其他变量中显示出来。
我可以使用下面的数组推送来做到这一点,但有什么不同的方法吗?
@php
wp_reset_postdata();
global $excludeHome;
global $excludePostSlide;
array_push($excludeHome, $excludePostSlide[0], $excludePostSlide[1], $excludePostSlide[2], $excludePostSlide[3], $excludePostSlide[4], $excludePostSlide[5]);
$args = [
'post_type' => 'post',
'orderby' => 'date',
'category_name' => 'auto',
'posts_per_page' => 6,
'no_found_rows' => true,
'post__not_in' => $excludeHome,
];
$querySlider = new WP_Query($args);
@endphp
【问题讨论】:
标签: php wordpress wordpress-theming custom-wordpress-pages