在URI请求参数表格中使用Union/Introsection Query_posts变量?
-
16-10-2019 - |
题
通常,当我创建某种形式的查询时,我会为这样的论点使用数组:
$postslistArgs = array( 'child_of' => 320, 'parent' => 320 ); $postslist = get_pages($postslistArgs);
但是,其他时候,当我需要/想要使用URI式查询参数时:
get_pages('child_of=320&parent=320');
这是直接的 post__not_in
那需要一系列ID吗?
解决方案
WP_QUERY使用PHP的本地 parse_str
功能,使用以下结构表示数组:
'post__not_in[]=1&post__not_in[]=2&post__not_in[]=3'
是相同的
array(
'post__not_in' => array( 1,2,3 )
)