Hi,
I have field group with repeater which in turn have 3 sub fields.
1. Product category—- which is taxonomy
2. Product——which is post object
2. Activity—– which is another taxonomy
How to show these data in front end. The following code returns ID of product category when we set return type as term id. But when we set it as term object there is no result. Can someone guide me on this
<?php
// check if the repeater field has rows of data
if( have_rows(‘product_details’) ):
// loop through the rows of data
while ( have_rows(‘product_details’) ) : the_row();
// display a sub field value
the_sub_field(‘product_category’);
endwhile;
else :
// no rows found
endif;
?>
Hi @madhan2085
I’m afraid the the_sub_field()
function is not an appropriate function to use with the taxonomy field. Kindly use the get_sub_field()
function like this instead:
$the_product_cat = get_sub_field(‘product_category’);
print_r($the_product_cat);
These pages should give you more idea about it: https://www.advancedcustomfields.com/resources/taxonomy/, https://www.advancedcustomfields.com/resources/get_sub_field/.
I hope this helps 🙂
Hi @madhan2085
That’s weird. Could you please debug the repeater like this:
var_dump( get_field('product_details') );
If that doesn’t work, could you please provide the product ID like this:
var_dump( get_field('product_details', 99) );
Where ’99’ is product ID.
Also, could you please try to reproduce the issue on one of the WordPress’ stock themes (like Twenty Sixteen) with other plugins deactivated? If it disappears, then you can activate the theme and plugins one by one to see which one causes the issue.
If still no joy, could you please share the JSON export file of your field group so I can test it out on my installation?
Thanks 🙂
Hi i have attached the json file. Still no output.
Hi @madhan2085
It seems that you use the repeater in the “job listing” post type. In this case, you need to pass the job listing ID instead of the product ID. If that doesn’t work, could you please try the following code?
global $post;
var_dump( get_field('product_details', $post->ID) );
Also, don’t forget to change the “Return Value” to “Term Object”.
If still no joy, could you please open a new ticket and provide temporary admin credentials to your site? You can open a new ticket here: https://support.advancedcustomfields.com/new-ticket. Also, please don’t forget to explain the issue again and provide the link to this thread.
Thanks 🙂
The topic ‘Acf front end for Repeater which has taxonomy as subfield’ is closed to new replies.
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 Privacy Policy. If you continue to use this site, you consent to our use of cookies.