Reputation: 239
I'm sure this should be simple, but doesn't seem to be working for me.
$query1 = new WP_Query('posts_per_page=-1'); // getting all posts works fine
$query1 = new WP_Query('tag=slug'); // getting the slug works fine
but putting the 2 together ain't happening. I've tried:
$query1 = new WP_Query('posts_per_page=-1', 'tag=slug');
and...
$query1 = new WP_Query( array( 'posts_per_page' => -1, 'tag' => 'slug' ) );
No luck.
Upvotes: 1
Views: 1790
Reputation: 22241
Try:
$query = new WP_Query( 'posts_per_page=-1&tag=cooking' );
echo '<pre>' . print_r( $query->posts, 1 ) . '</pre>'; // this line is for debugging purposes only.
You are missing the ampersand '&'.
See:
http://codex.wordpress.org/Class_Reference/WP_Query#Tag_Parameters
Upvotes: 1