custom field - Print terms with taxonomy and metabox value

admin2025-06-05  6

I create metabox serial_language with ACP plugin into custom taxonomy name is serial.

And I want to get only terms, in which custom field value is english, arabic.

How to get only terms which have custom fields value english or arabic?

$wcatTerms = array(
    'get_terms' => 'serial',
    'hide_empty' => 0, 
    'parent' =>0,
    'tax_query' => array(
    'relation' => 'AND',
        array(
            'get_terms' => 'serial',
            'field' => 'serial_language',
            'value' => array( 'english', 'arabic' ),
        )
));
foreach($wcatTerms as $wcatTerm) :
    echo '<a href="' .get_term_link( $wcatTerm->slug, $wcatTerm->taxonomy ). '">' .$wcatTerm->name. '</a>';
endforeach; 

I create metabox serial_language with ACP plugin into custom taxonomy name is serial.

And I want to get only terms, in which custom field value is english, arabic.

How to get only terms which have custom fields value english or arabic?

$wcatTerms = array(
    'get_terms' => 'serial',
    'hide_empty' => 0, 
    'parent' =>0,
    'tax_query' => array(
    'relation' => 'AND',
        array(
            'get_terms' => 'serial',
            'field' => 'serial_language',
            'value' => array( 'english', 'arabic' ),
        )
));
foreach($wcatTerms as $wcatTerm) :
    echo '<a href="' .get_term_link( $wcatTerm->slug, $wcatTerm->taxonomy ). '">' .$wcatTerm->name. '</a>';
endforeach; 
Share Improve this question asked Dec 14, 2018 at 13:48 F.AF.A 255 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 1

Try This:

$args = array(
    'hide_empty' => false,
    'relation' => 'OR',
          array(
            'key' => 'serial_language',
            'value' =>'english', 
            'compare' => 'LIKE'
          ),
          array(
            'key' => 'serial_language',
            'value' =>'arabic', 
            'compare' => 'LIKE'
          ),
    'taxonomy'  => 'serial',
    );
    $terms = get_terms( $args );

hope this will help

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1749099539a316356.html

最新回复(0)