Use union/intersection query_posts variables in uri request parameter form?

wordpress.stackexchange https://wordpress.stackexchange.com/questions/127

  •  16-10-2019
  •  | 
  •  

Pergunta

Usually when I create some form of query, I use an array for my arguments like this:

$postslistArgs = array( 
    'child_of' => 320,
    'parent' => 320
);                          
$postslist = get_pages($postslistArgs);

There are other times, however, when I need/want to use URI-style query parameters like this:

get_pages('child_of=320&parent=320');

That's all straightforward, but is there any way possible to use the URI parameter style on more advance union/intersection queries such as post__not_in that require an array of IDs?

Foi útil?

Solução

WP_Query uses PHP's native parse_str function, which uses the following structure to denote arrays:

'post__not_in[]=1&post__not_in[]=2&post__not_in[]=3'

is the same as

array(
  'post__not_in' => array( 1,2,3 )
)
Licenciado em: CC-BY-SA com atribuição
Não afiliado a wordpress.stackexchange
scroll top