从中,您似乎希望按类别对所有产品进行分组。您的查询似乎是正确的,除了$term_slug 不需要在引号中。
$tax_post_args = array(
\'post_type\' => \'bpo_microsoftoffice\',
\'posts_per_page\' => 999,
\'order\' => \'ASC\',
\'tax_query\' => array(
array(
\'taxonomy\' => \'bpo_microsoftoffice_reg\',
\'field\' => \'slug\',
\'terms\' => $term_slug
)
)
);
编辑:
方法1:
如果只需要编写的查询,请使用WP_Query($tax_post_args );.
方法2:
如果你两者都想要category 加custom_taxonomy, 添加\'category\' => $cat_id, 在里面$tax_post_args.
所以
$tax_post_args = array(
\'post_type\' => \'bpo_microsoftoffice\',
\'posts_per_page\' => 999,
\'order\' => \'ASC\',
\'tax_query\' => array(
\'relation\' => \'OR\',
array(
\'taxonomy\' => \'bpo_microsoftoffice_reg\',
\'field\' => \'slug\',
\'terms\' => $term_slug
),
array(
\'taxonomy\' => \'category\',
\'field\' => \'slug\',
\'terms\' => $cat_id
),
)
);
以及使用WP\\u查询($tax\\u post\\u args);
这是假设你post_type 正在进行category 以及bpo_microsoftoffice_reg 作为分类法。要是…就好了bpo_microsoftoffice_reg 如果已指定,请使用第一种方法。