Support

Account

Home Forums Front-end Issues Woocommerce Category Feature Image

Unread

Woocommerce Category Feature Image

  • I’m wanting to display a feature image for each Woocommerce category. I’ve got the image upload showing up for the category, and the URL of the image being returned as a background on the code, but the image itself does not show.

    Code is as follows:
    <div id=”category-feature-image”>
    <?php
    // get the current taxonomy term
    $term = get_queried_object();
    // vars
    $image = get_field(‘category-feature-image’, $term);
    ?>
    <style type=”text/css”>
    background-image: url(<?php echo $image[‘url’]; ?>);
    height: 400px;
    }
    </style>
    </div>

    The code returned on the site is below:

    <div id=”category-feature-image” style=”height:400px;”>
    <style type=”text/css”>
    background-image: url(http://127.0.0.1/site/wp-content/uploads/2019/11/background.jpg);
    height: 400px;
    }
    </style>
    </div>

    Any ideas why it is generating the url for the image (and changes depending on the category I’m viewing), but not actually displaying it.

    Thanks.

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.