Support

Account

Home Forums Front-end Issues display Category Image in loop and link

Solved

display Category Image in loop and link

  • hello forum
    i want to display display Category Image in loop
    but this code and work but not link
    how to fix?

           <?php 
        $types = get_terms( array( 
            'taxonomy' => 'company_category', 
            'hide_empty' => true, 
            ) );
            foreach($types as $type) { ?>
        <a class="author">
            <?php $image = get_field('company_image', 'company_category_' . $type->term_id . '' ); 
                        if ( has_term( $type->term_id, 'company_category')) {
                        echo '<img class="imagenes" src="' . $image['url'] . '" /> ' . '<div class="name">'. $type->name . '</div>' . '<small>'. $type->name . '</small>'; 
                        } 
                    ?>
        </a>
        <?php } ?>

    This Preview

    pleases someone help
    Thank.

  • Is this what you mean to do?

    echo  '<a href="' . get_term_link( $type ) . '">'
        . '<img class="imagenes" src="' . $image['url'] . '" />'
        . '</a>'
        . '<div class="name">' . $type->name . '</div>'
        . '<small>' . $type->name . '</small>';
Viewing 2 posts - 1 through 2 (of 2 total)

The topic ‘display Category Image in loop and link’ is closed to new replies.