Answer the question
In order to leave comments, you need to log in
How to display the ACF field under the category heading?
Good afternoon. How to insert text under the title of a category, or rather a subcategory?
The text is set by the ACF plugin and should be output by the ml-atr-cat tag.
It was possible to display only under the title, but the prescribed meta is not displayed in any way.
function my_woocommerce_after_shop_loop() {
$cate = get_queried_object();
$cateID = $cate->term_id;
$mycat = 'product_cat_' . $cateID;
$my_gallery = get_field('ml-acf-pc-atr', $mycat);
echo '' . ( $my_gallery ) . '';
}
add_action('woocommerce_subcategory_count_html', 'my_woocommerce_after_shop_loop', 10, 2);
Answer the question
In order to leave comments, you need to log in
Here is the working code
function add_custom_field_subcat( $category ) {
$value = get_field('category_description', 'product_cat_'. $category->term_id);
echo $value;
}
add_action( 'woocommerce_before_subcategory_title', 'add_custom_field_subcat', 15 );
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question