$conf, $runtime; function_exists('chdir') AND chdir(APP_PATH); $r = 'mysql' == $conf['cache']['type'] ? website_set('runtime', $runtime) : cache_set('runtime', $runtime); } function runtime_truncate() { global $conf; 'mysql' == $conf['cache']['type'] ? website_set('runtime', '') : cache_delete('runtime'); } register_shutdown_function('runtime_save'); ?>custom field - Print terms with taxonomy and metabox value|Programmer puzzle solving
最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

custom field - Print terms with taxonomy and metabox value

matteradmin9PV0评论

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

Post a comment

comment list (0)

  1. No comments so far