So far, Said’s code doesn’t display anything in my website. Maybe the theme is probably responsible of this situation.
Have a look to what I did : https://www.awesomescreenshot.com/video/5721907?key=4153c64b2fa5aa641bab9725fe3e7c45
I am doing something wrong?
@jarvis About the code which could go into the archive-product.php file, I guess there is a very precise location in the existing code where to add this extra code?
Hello everybody
Here is the answer I received this morning (French time) of Said, from the official ACF support:
With the field’s Location rule set as Taxonomy is equal to product_cat, the field should appear on your individual product category edit page. With the code below added in functions.php, the field value displays just fine on the individual category archive in the frontend as shown in this recording: https://www.awesomescreenshot.com/video/5711245?key=aa4a06a3a6ab345566493738b7aad9d5
add_action( ‘woocommerce_after_main_content’, ‘extra_description’ );
function extra_description() {
global $wp_query;
$product_cat = $wp_query->get_queried_object();
$cat_ID = $product_cat->term_id;
$extra_info = get_field( ‘product_extra’, ‘category_’ . $cat_ID );
if( $extra_info ){
echo $extra_info;
}
}
So i will try it out and let you know how it goes.
Still nothing…
The code is there, but nothing is displayed under the products grid (https://fleursdemontagne.com/categorie-cbd/huile-cbd/ for example)
I thought that some code should be integrated in the archive-product.php (https://woocommerce.github.io/code-reference/files/woocommerce-templates-archive-product.html). Wrong track?
Thank you @Jarvis.
I added this code at the end of the functions.php file of the main theme of the website, and replaced every “extra_description” characters strings by the name of my field (“contenu_categorie”) (except in the 2 first lines of the code of course).
… Nothing has changed in the front end, even if I clear the cache (of course, I added some contents in my fields from the back-office)…
Sorry, it does not work for me…
I have exactly the same need than @peterpans
I created the this rule: Taxonomy is equal Category (product_cat), then I am able to provide some content for each product category. But when I try to add some php code to display it, I have no good result, as I am not a developer and tutorials I found are not detailed enough…
Hello everybody
I had the same question. Do I have to add this code into the woocommerce/archive-product.php file? If so, between which lines?
Thank you for your help.
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 Cookie Policy. If you continue to use this site, you consent to our use of cookies.