如何使用选项值过滤WordPress分类?

时间:2018-08-14 19:33:06

标签: php wordpress filter custom-taxonomy taxonomy-terms

我有一个自定义分类法,我可以通过以下代码检索分类法条款

$terms = get_terms( array(
    'taxonomy' => 'coupon_store', 

) );

我有两个选择1.affiliate_provider,2.program_id 我通过下面的代码添加这些选项

$term_meta = array("affiliate_provider"=>'ABC',"program_id"=>'123');
update_option( "taxonomy_term_$termID", $term_meta ); 

我还可以通过以下代码获得该词的两个选项

$term_meta = get_option( "taxonomy_term_$termID" ); 

这是我的问题:- 我想基于 affiliate_provider 选项在“ get_terms” 上应用过滤器,我尝试使用以下代码,但未成功

$terms = get_terms( array(
    'taxonomy' => 'coupon_store',
    'meta_query' => array(
         array(
            'key'       => 'affiliate_provider',
            'value'     => 'adrecord',
            'compare'   => '='
         )
    )
    'hide_empty' => false,

) );
print_r($terms);

有人可以推荐我一个解决方案吗?我尝试了很多,并遵循了论坛,但没有解决方法...

0 个答案:

没有答案