Support

Account

Home Forums Front-end Issues ACF image is showing h and it's not showing in front end.

Solved

ACF image is showing h and it's not showing in front end.

  • hi,

    My image and alt was working fine before but I just noticed my images and alt is not showing and it’s showing “h”. I didn’t change anything. My backend is showing the image. I’m wondering why is not working. Please see screenshit. This is the code.

    <?php
    $cat = get_query_var('Category');
    $args = array(
        'child_of' => $cat,
        'orderby' => 'date',
        'order' => 'ASC'
    );
    
    $categories = get_categories($args);
    
    foreach($categories as $category) { 
        $image = get_field('cat_thumbnail_image', 'category_'. $category->term_id .'');
    
        echo '<article class="work-wrap">
        <a href="' . get_category_link( $category->term_id ) . '" title="' . sprintf( __( "View all posts in %s" ), $category->name ) . '" class="work-img">
            <img src="' . $image['url']; ?>" alt="<?php echo $image['alt'] . '">
            <h2>'. $category->name . '</h2>
        </a>
    </article>';
    }
    ?>
    
    

    backend showing image
    front end is not showing the image

  • what is being returned

    
    $image = get_field('cat_thumbnail_image', 'category_'. $category->term_id .'');
    // dump returned value
    var_dump($image);
    
  • How do I make the image to show up in front end? Please help

  • Please answer the question that I asked.
    I am attempting to help you figure out why it’s not showing. Your code does not indicate a reason. Debugging is required.

  • Please see screenshot. It showing the img url. Let me know if u see the screenshot.

  • This means that you image field is returning the URL of the image. This means that you are expecting it to return an image array $image['url']

    Check your field settings to make sure that it is set to return an image array and not the image URL.

  • Thank you. I change it to return an image array and it works now.

Viewing 7 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic.