I am using ACF with WP-Ecommerce. On the wpsc-products_page I am trying to display a custom text field. The field appears on the page with the text on the backend. But I can’t get it to display using `<?php if( get_field( “longdesc” ) ): ?>
<?php the_field( “longdesc” ); ?>
<?php endif;?>`
I tired this but it didn’t display.
$variable = get_field('longdesc', 'wpsc_product_category');
echo $variable;
I changed it to `$variable = get_field(‘longdesc’, ‘wpsc_product_category_15’);
echo $variable;`
and it worked. How can I have it so its dynamic loading the current category?
I think it should be something like this
$variable = get_field('longdesc', 'wpsc_product_category_'.$category->term_id);
echo $variable;
I found the solution in the examples online.
$queried_object = get_queried_object();
$taxonomy = $queried_object->taxonomy;
$term_id = $queried_object->term_id;
// load variable for this taxonomy term (term object)
$variable = get_field('longdesc', $queried_object);
// load variable for this taxonomy term (term string)
$variable = get_field('longdesc', $taxonomy . '_' . $term_id);
echo $variable;