我确定这应该很简单,但似乎并不适合我。
$query1 = new WP_Query('posts_per_page=-1'); // getting all posts works fine
$query1 = new WP_Query('tag=slug'); // getting the slug works fine
但是把2放在了一起。我试过了:
$query1 = new WP_Query('posts_per_page=-1', 'tag=slug');
和...
$query1 = new WP_Query( array( 'posts_per_page' => -1, 'tag' => 'slug' ) );
没有运气。
答案 0 :(得分:1)
尝试:
$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.
您错过了&符号&amp;&#39;。
请参阅:
http://codex.wordpress.org/Class_Reference/WP_Query#Tag_Parameters