With HUB2’s kind help this solution finally worked! Thanks a ton HUB2!
<?php
$term_id = get_queried_object()->term_id;
$post_id = 'product_cat_'.$term_id;
$custom_field = get_field('custom_category_content', $post_id); // My Advanced Custom Field Variable
?>
<div><?php echo $custom_field; ?> </div> <?php // Get Advanced Custom Field Value ?>
Both tests confirmed it was returning the term ID. The first returned 16 and the second returned:
stdClass Object ( [term_id] => 16 [name] => Clothing [slug] => clothing [term_group] => 0 [term_taxonomy_id] => 16 [taxonomy] => product_cat [description] => [parent] => 0 [count] => 12 [filter] => raw )
As for woocommerce support on this particular subject, there isn’t much out there at all, and what I’ve found didn’t work. At the start, it seemed like something I could track down because adding a custom WYSIWYG field above the main woocommerce product loop would allow for a simple way to customize the page content for each product category… but nothing. I even posted the same issue on WooCommerce’s support site and still nothing after 3 days. So strange.
It’s still not showing up. I added the code below to my taxonomy template:
<div>
<?php
$term_id = get_queried_object()->term_id;
$post_id = ‘taxonomy-name_’.$term_id;
the_field('custom_category_content', $post_id);
?>
</div>
I also double checked my custom field location. It’s set to: “Taxonmony Term” is equal to “Product Categories”. Also, do I still need the woocommerce “add_action” function (in my functions file)? IF so, is the one I have correct? So sorry for this… thanks again.
First of all, thank you for the assistance. Am I correct in thinking that this would get placed into the custom taxonomy-product_cat.php file itself:
<?php the_field('custom_category_content','clothing'); ?>
The other question is where do I place the code (show below) that you suggested? In the template file or within the function in the functions file?
$term_id = get_queried_object()->term_id;
$post_id = ‘taxonomy-name_’.$term_id;
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
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 Privacy Policy. If you continue to use this site, you consent to our use of cookies.