Hi guys,
I’m trying to display the URL of a wooCommerce category taxonomy but am getting a fatal error.
I’m using..
Field type taxonomy
Taxonomy product_cat
Return value Term object
This is inside a repeater..
<?php echo the_sub_field('category_button_url'); ?>
The error..
Catchable fatal error: Object of class WP_Term could not be converted to string in /Applications/XAMPP/xamppfiles/htdocs/r-com-website/wp-content/plugins/advanced-custom-fields/core/api.php on line 690
Thank you!
Hi @klevermedia
You can’t echo the_sub_field() function as it already echoing it’s value by itself. Also, you can’t echo a Taxonomy field because it is an object, not a string. I think you can do it like this:
$theTerms = get_sub_field('category_button_url');
echo get_term_link( $theTerms );
This page should give you more idea about it: http://www.advancedcustomfields.com/resources/taxonomy/.
I hope this helps.
Awesome, that’s just what I needed. Thank you for your help!