你可以通过slug而不是name来获取帖子。像这样:
$posts = get_posts(array(
\'post_type\' => \'coupon\',
\'numberposts\' => -1,
\'post_status\' => array(\'publish\', \'unreliable\', \'draft\'),
\'tax_query\' => array(
array(
\'taxonomy\' => \'stores\',
\'field\' => \'slug\',
\'terms\' => array( \'new-store\' ),
\'include_children\' => false
)
)
));
或者您可以通过术语id获取帖子。如下所示:
$posts = get_posts(array(
\'post_type\' => \'coupon\',
\'numberposts\' => -1,
\'post_status\' => array(\'publish\', \'unreliable\', \'draft\'),
\'tax_query\' => array(
array(
\'taxonomy\' => \'stores\',
\'field\' => \'term_id\',
\'terms\' => array( 4 ),
\'include_children\' => false
)
)
));
在这里,您可以找到如何知道术语id的指南:
https://facetwp.com/how-to-find-a-wordpress-terms-id/