我希望你今天身体好,
我的问题是,如果我只想通过某种分类法从自定义帖子类型进行查询;
为了保持它的流线型,让我们以下面为例;
Custom Post Type: “产品”
Taxonomy: “类别”
Categories within \'Categories\';
(1)类别1(2)类别2(3)类别3所以我想从自定义帖子类型查询帖子\'Products\' 和内部\'Category 1\'
如何做到这一点?
下面是我的代码,用于查询自定义帖子类型并尝试查询分类类别。
<?php
$paged = (get_query_var(\'paged\')) ? get_query_var(\'paged\') : 1;
$post_per_page = -1; // -1 shows all posts
$do_not_show_stickies = 1; // 0 to show stickies
$args=array(
\'post_type\' => \'products\',
\'taxonomy\' => \'category-1\',
\'paged\' => $paged,
\'posts_per_page\' => $post_per_page,
\'order\' => \'ASC\',
);
$temp = $wp_query; // assign orginal query to temp variable for later use
$wp_query = null;
$wp_query = new WP_Query($args);
if( have_posts() ) : while ($wp_query->have_posts()) : $wp_query->the_post(); ?>
SO网友:Alvic
含分类法、字段和术语的tax\\u查询数组。其中terms->business是分类->job\\u类别的类别
$args = array(
\'post_type\' => \'featured_job\',
\'post_status\' => \'publish\',
\'posts_per_page\' => 9999999,
\'orderby\' => \'date\',
\'order\' => \'DES\',
\'tax_query\' => array(
array(
\'taxonomy\' => \'job_category\',
\'field\' => \'slug\',
\'terms\' => \'business\',
),
),
);