Support

Account

Home Forums Front-end Issues Category list with image

Unread

Category list with image

  • Hi, I try to create list of child category with images thumbs.

    I add new field to taxonomy “image_category” and now I try to add this image to the list:

    <?php 
    
    $args = array('parent' => 3);
    $categories = get_categories( $args );
    
    $term = get_queried_object();
    $image_category = get_field('image_category', $term);
    
    foreach($categories as $category) { 
    
        echo '<div class="col-md-3 col-sm-12 col-xs-12 lista-kraje text-center pb-3"><img src="' . $image_category .  '"><h3><a href="' . get_category_link( $category->term_id ) . '" title="' . sprintf( __( "View all posts in %s" ), $category->name ) . '" ' . '>' . $category->name.'</a> </h3> ';
        echo '<p> <strong>Number post:</strong> '. $category->count . '</p></div>';  
    }
    
    ?>

    I see category list, name, number post. Only image dont work.

    Image link dont show. I have on consol only “img src=(unknown)”. What am I doing wrong?

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.