Home › Forums › Add-ons › Repeater Field › Custom Taxonomy in Repeater Field
Hello
I have setup a custom post type called ‘products’ within this post type there is a custom taxonomy called ‘ingredients’. Please see attached screenshot for how this is setup in ACF.
I have setup a template called single-product.php with the following code:
<?php
/**
PostType Page Template: Product
*/
get_header(); ?>
<div id="b_primary" class="b_content-area">
<main id="b_main" class="b_site__main" role="main">
<?php while ( have_posts() ) : the_post(); ?>
<!-- START product information -->
<div class="toptext">If you have any enquiries, please click here to contact us.</div>
<div class="toptext">Please ensure you include all the products information that you wish to enquire about.</div>
<div class="tableproduct">
<table>
<tr>
<th><div class="tabletitle">PRODUCT NAME</div></th>
<th><div class="tableresult"><?php wp_title(''); ?></div></th>
</tr>
<tr>
<td><div class="tabletitle">PRODUCT DESCRIPTION</div></td>
<td><div class="tableresult"><?php the_field('product_description'); ?></div></td>
</tr>
<tr>
<td><div class="tabletitle">BRAND</div></td>
<td><div class="tableresult"><?php the_field('brand'); ?></div></td>
</tr>
<tr>
<td><div class="tabletitle">BARCODE</div></td>
<td><div class="tableresult"><?php the_field('barcode'); ?></div></td>
</tr>
<tr>
<td><div class="tabletitle">Ingredients (INCI Name)<br><div class="tablesubtitle">NOTE: Ingredients are listed in decreasing order of quantity.</div></div></td>
<td><div class="tableresult">
<!--START ingredients pull through-->
<?php
if( have_rows('ingredients-INCI') ):
while ( have_rows('ingredients-INCI') ) : $row = the_row();
$type = $row['ingredients-INCI-group'];
echo "Type: " . $type . " ";
endwhile;
endif;
?>
<!--END ingredients pull through-->
</div></td>
</tr>
<tr>
<td><div class="tabletitle">Fragrance Ingredients (INCI Name)<br><div class="tablesubtitle">NOTE: Fragrance Ingredients are those which require listing under EC648/2004 on detergents.</div></div></td>
<td><div class="tableresult">
<!--START ingredients pull through-->
RESULTS HERE
<!--END ingredients pull through-->
</div></td>
</tr>
</table>
<div class="tabletitleother">OTHER INFORMATION</div>
<div class="tableotherresults">The above formulation is for products manufactured between <?php the_field('date_from'); ?> and <?php the_field('date_to'); ?></div>
<div class="tableyellow">INCI / CAS / Ingredient information CLICK HERE or HERE</div>
</div>
<!-- END product information -->
<?php endwhile; // End of the loop. ?>
</main><!-- #b_main -->
</div><!-- #b_primary -->
<center><a href="http://products.safetydata.org"><div class="buttonmore">START NEW SEARCH</div></a></center>
<?php get_sidebar(); ?>
<?php get_footer(); ?>
for some reason it’s not pulling through the select taxonomies on the repeater field, this is what is displayed:
You’ll see that it’s pulling though ‘Type:, Type:’ so it knows there are two to pull though however it’s not pulling through the name of the taxonomy.
I’ve have searched and searched and tried all sorts of snippets on various posts to try and get this working but nothing seems to.
I’m pulling my hair out! Please help….
Sorry forgot to add – this is what the custom post type looks like:
You have the field set up to return a term object, and I think you need to use get_sub_field()
, I’m not sure what this is doing $type = $row['ingredients-INCI-group'];
if( have_rows('ingredients-INCI') ):
while ( have_rows('ingredients-INCI') ) : $row = the_row();
$type = get_sub_field('ingredients-INCI-group');
echo "Type: " . $type->name . " ";
endwhile;
endif;
You must be logged in to reply to this topic.
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!
🚀 This week’s session of ACF Chat Fridays dips into the preliminary results of our first ever user survey. Don’t miss it! https://t.co/3UtvQbDwNm pic.twitter.com/kMwhaJTkZc
— Advanced Custom Fields (@wp_acf) May 9, 2023
© 2023 Advanced Custom Fields.
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 Cookie Policy. If you continue to use this site, you consent to our use of cookies.