基于来自的答案ilgıt-yıldırım 上面,两个get_term_meta
声明和$key == \'meta_value\'
报表需要包含$term>term_id
.
下面是一个完整的示例,包括自定义$wp_query
请求:
$term_args = array( \'taxonomy\' => \'your-taxonomy\' );
$terms = get_terms( $term_args );
$term_ids = array();
foreach( $terms as $term ) {
$key = get_term_meta( $term->term_id, \'term-meta-key\', true );
if( $key == \'term-meta-value\' ) {
// push the ID into the array
$term_ids[] = $term->term_id;
}
}
// Loop Args
$args = array(
\'post_type\' => \'posts\',
\'tax_query\' => array(
array(
\'taxonomy\' => \'your-taxonomy\',
\'terms\' => $term_ids,
),
),
);
// The Query
$featured = new WP_Query( $args );