Friday , December 20 2024

ACF not showing up in WooCommerce categories

By default, ACF fields can be displayed like this:

<?php the_field('slogan');?>

or like this:

<?php if( get_field("slogan") ): ?>
<?php the_field( "slogan" ); ?>
<?php else :?>
Custom text if needed.
<?php endif; ?>

In WooCommerce, this construction does not work, below are correct code example:

$queriedObject = get_queried_object();
echo get_field('slogan','product_cat_'.$queriedObject->term_id);

$queriedObject = get_queried_object();
echo get_field('slogan','term_'.$queriedObject->term_id);

$queriedObject = get_queried_object();
echo get_field('slogan', $queriedObject);

About admin

Hi there! My name is Iryna, I am a web developer from Ukraine. While working on freelance projects I often face different technical issues and in this blog I publish articles on how to solve them. I am also interested in digital drawing and in this blog you will find brief tutorials that helped me and hopefully can help you as well.

Check Also

How to remove 404 //fonts.gstatic.com and //fonts.googleapis.com from WordPress head section

I tried solutions with functions that should remove from head and , but a very …

Leave a Reply

Your email address will not be published. Required fields are marked *