繁体   English   中英

WordPress的WP查询显示所有带有特定标签的帖子

[英]Wordpress WP Query display all posts with specific tag

我相信这应该很简单,但似乎对我没有用。

$query1 = new WP_Query('posts_per_page=-1'); // getting all posts works fine
$query1 = new WP_Query('tag=slug'); // getting the slug works fine

但是将这两个放在一起不会发生。 我试过了:

$query1 = new WP_Query('posts_per_page=-1', 'tag=slug');

和...

$query1 = new WP_Query( array( 'posts_per_page' => -1, 'tag' => 'slug' ) );

没运气。

尝试:

$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.

您缺少与号“&”。

看到:

http://codex.wordpress.org/Class_Reference/WP_Query#Tag_Parameters

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM