Answer the question
In order to leave comments, you need to log in
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
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 questionAsk a Question
731 491 924 answers to any question