L
L
lakegull2016-03-02 16:50:51
WordPress
lakegull, 2016-03-02 16:50:51

How to display the value of the description field in a taxonomy?

Good afternoon.
Editing plugin code. Now instead of the %name% value, the value of the taxonomy name (name) is substituted. What needs to be changed in the code so that the value from the description field is substituted instead of %name%?

<?php	
      if( $element['type'] == 'hierarchical-taxonomies' ):
          $args = array(
            'orderby'		=> 'name', 
            'order'			=> 'ASC',
            'hide_empty'	=> true,
            'parent'		=> 0
          );
          $terms = get_terms( $data_value, $args );
          $terms = create_hierarchical_select( $terms );
          ksort( $terms );
          foreach( $terms as $tkey => $tval ):
            if( $tkey != 0 ):
              $n = get_term_by( 'id', $tkey, $data_value );
              $n = $n->name;
            endif;
            
            if( isset( $n ) ):
              $select_label = preg_replace( '^%name%^', $n, $element['select_label'] );
            else:
              $select_label = preg_replace( '^%name%^', $element['fieldname'], $element['select_label'] );
            endif;
            
          ?>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ivan Kozlov, 2016-03-03
@trampick

if I understand correctly, then:
$n = $n->name;
should be changed to
$n = $n->description;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question