Reputation: 45
I am trying to print an ACF
field after the WooCommerce archive page title.
I use the following code but not working.
woocommerce_page_title();
global $post;
if( get_field('acf_field',$taxonomy . '_' . $termId) ):
$taxonomy = get_query_var('taxonomy');
$term_id = get_queried_object()->term_id;
the_field('acf_field', $taxonomy . '_' . $term_id);
else:
endif;
Upvotes: 1
Views: 1345
Reputation: 9097
I'm not sure why you used global $post
variable here, since you have not provided the entire code but I don't think you need it for outputting the acf
field.
So try the following snippet:
woocommerce_page_title();
$term_id = get_queried_object()->term_id;
$taxonomy = get_queried_object()->taxonomy;
$custom_field_value = get_field('you_acf_field_here', $taxonomy . '_' . $term_id);
if ($custom_field_value) :
echo $custom_field_value;
else :
echo 'NO CUSTOM FIELD FOUND!';
endif;
Upvotes: 4