• I have been using WP_Query() in a simple manner such as
    $myquery= new WP_Query( 'tag=dogs' );

    I see a more complicated use of WP_Query using an array. Why is an array needed and under what circumstances should I use an array rather than the simpler method?

Viewing 1 replies (of 1 total)
  • I think your specific example is perfectly readable, but IMO, arrays are easier to read when you’re passing a large number of arguments to WP_Query:

    $args = array(
      'foo'  => 'bar',
      'baz'  => false,
      'qux'  => 4,
      'blah' => 'blah blah'
    );
    
    $query = new WP_Query( $args );
Viewing 1 replies (of 1 total)
  • The topic ‘$arg array use with WP_Query()’ is closed to new replies.