I'm using the Advanced Custom Fields (ACF) Plugin. On the WooCommerce product category, I want to have a content area for seo. ACF would help me but doesn't work, as nothing is shown on the front end of the site.
content-product.php
has the the extra field:
<li <?php post_class(); ?> style="max-width:<?php echo $column_width; ?>px">
<div class="mk-product-holder">
<?php do_action( 'woocommerce_before_shop_loop_item' ); ?>
<div class="mk-love-holder">
<?php if( function_exists('mk_love_this') ) mk_love_this(); ?>
</div>
<h3><a href="<?php echo get_permalink();?>"><?php the_title(); ?></a>
// Here is the extrafield SEO-text, the field is registered in fields with name "extratext"
<?php echo get_field('extratext'); ?>
</h3>
</div>
</li>
WooCommerce Category Screenshot: http://www.directupload.net/file/d/3952/kzb8dcjk_png.htm
You haven't set the $postId
parameter for the get_field()
function, so it's defaulting to the current post object (which will probably be the first post in the category).
See the Get a value from other places section in the documentation for instructions on how to get a field from other places.
So you'll want to write something like this:
<?php
$queriedObject=get_queried_object();
echo get_field('extratext','product_cat_'.$queriedObject->term_id);
?>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With