您可以使用wp_get_object_terms() 然后把其中的一些/全部传给WP_Query.
$terms = wp_get_object_terms( $post_id, \'packages\', array( \'fields\' => \'ids\' ) );
$args = array(
\'post_type\' => \'proposals\',
\'tax_query\' => array(
array(
\'taxonomy\' => \'packages\',
\'terms\' => $terms
)
),
);
$related = new WP_Query( $args );
如果当前提案有多个包,这将返回其中任何包中的提案列表。您可以添加
\'operator\' => \'AND\' 到
WP_Query $args 仅限于所有相同包中的提案。