Home Forums General Issues Custom WYSIWYG Field in WooCommerce Product Category


Custom WYSIWYG Field in WooCommerce Product Category

  • I’m using ACF and WooCommerce and would like to display a custom WYSIWYG field for my product categories. While I have seen this covered before, I’m still a little confused regarding just how to do this.

    Here’s the code I’ve been trying out (with no luck so far):

    $term = get_field('about_this_product_category', 'product-cat');
    echo $term

    My goal here is to display the results of this field for the current product category. I have seen where you can specify a specific product category in your code, but I’d rather have it automatically display results if possible.

    Any ideas of what I’m doing wrong?

  • Eventually figured this out! FYI, here’s the code in case it helps anyone. The name of my WYSIWYG field is ‘about_this_product_category’, which you would replace with your own field name.

    // vars
    $queried_object = get_queried_object(); 
    $taxonomy = $queried_object->taxonomy;
    $term_id = $queried_object->term_id;  
    // load desc for this taxonomy term (term object)
    $thumbnail = get_field('about_this_product_category', $queried_object);
    // load desc for this taxonomy term (term string)
    $thumbnail = get_field('about_this_product_category', $taxonomy . '_' . $term_id);
    <?php the_field( 'about_this_product_category', $queried_object ); ?>  

    I copied the archive-product.php from the WooCommerce plugin directory into a new /woocommerce/ folder inside my theme.

  • Thanks for this, really helped me out as i have been struggling with this for a while now.

  • Hi, I keep getting:

    Notice: Undefined property: stdClass::$taxonomy


    Notice: Undefined property: stdClass::$term_id

    on the base shop page, which is an archive, however a page also.

    Anyone else experiencing this? Or can explain why it’s happening?


  • Thanks so much for this, have been searching for a solution for a couple hours! SO glad you posted this.

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

You must be logged in to reply to this topic.