URIリクエストパラメーター形式でUnion/Intersection Query_Posts変数を使用しますか?
-
16-10-2019 - |
質問
通常、何らかの形のクエリを作成するとき、私は次のような私の引数に配列を使用します:
$postslistArgs = array( 'child_of' => 320, 'parent' => 320 ); $postslist = get_pages($postslistArgs);
ただし、このようなURIスタイルのクエリパラメーターを必要とする/使用する必要がある場合もあります。
get_pages('child_of=320&parent=320');
それはすべて簡単ですが、URIパラメータースタイルをより多くの事前のユニオン/交差点クエリで使用する可能性のある方法はありますか 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 )
)
所属していません wordpress.stackexchange