Support

Account

Home Forums Front-end Issues Woocommerce Category Feature Image

Unread

Woocommerce Category Feature Image

    • winkweb

    • November 22, 2019 at 10:24 am

    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.

We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.