WP查询 - 无法按类别slug查询(WP Query - Unable to query by category slug)
我的自定义帖子中有四个类别“项目”类型是“现场”,“治疗”,“工作”和“播放”。 我有几个“项目”帖子没有我希望从档案页面中省略的类别。 在我的档案中,我的查询如下:
<?php $args = array( 'post_type' => 'projects','post_status' => 'publish', 'posts_per_page' => $projects_number, 'paged'=> $paged, 'category_name' => 'work,play,live,heal'); ?> <?php $wp_query = null; ?> <?php $wp_query = new WP_Query( $args ); ?> <?php if ( $wp_query->have_posts() ) : ?>但我的档案并没有退回任何项目。 我也尝试了带有id的'cat'参数,但也没有用。 我错过了什么?
I have four categories in my Custom Post Type of "projects" that are 'live', 'heal', 'work', and 'play'. I have a few 'projects' posts with no category that I would like to omit from the archive page. In my archive, my query is as follows:
<?php $args = array( 'post_type' => 'projects','post_status' => 'publish', 'posts_per_page' => $projects_number, 'paged'=> $paged, 'category_name' => 'work,play,live,heal'); ?> <?php $wp_query = null; ?> <?php $wp_query = new WP_Query( $args ); ?> <?php if ( $wp_query->have_posts() ) : ?>But my archive is not returning any projects. I also tried the 'cat' parameter with id's but no avail there either. What am I missing?
最满意答案
对于任何遇到这种情况的人来说......'category'参数需要在它自己的数组中
For anyone who comes across this...the 'category' argument needed to be in its own array
更多推荐
发布评论