Answer the question
In order to leave comments, you need to log in
How to display an image in your taxonomy?
Displaying my own taxonomy created in function.php using get_the_term_list
/**
* Создание собственной таксономии
*/
function create_my_taxonomies() {
register_taxonomy('actors', 'post', array(
'hierarchical' => false, 'label' => 'Участники',
'query_var' => true, 'rewrite' => true));
}
add_action('init', 'create_my_taxonomies', 0);
<?php echo get_the_term_list($post->ID, 'actors', '<h3>Участники</h3>', '<br/>', ''); ?>
function tax_img() {
$imgcat1 = get_field("imgcat1") ;
echo get_the_term_list($post->ID, 'actors', '<h3>Участники</h3>', '<img src="'.$imgcat1.'"/>'.'<br/>', '');
}
Answer the question
In order to leave comments, you need to log in
function tax_img() {
$cur_terms = get_the_terms( $post->ID, 'actors' );
foreach( $cur_terms as $cur_term ){
echo '<img src="';
the_field( 'imgtax', $cur_term );
echo '"/>';
echo '<a href="'. get_term_link( (int)$cur_term->term_id, $cur_term->taxonomy ) .'">'. $cur_term->name .'</a><br>';
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question