Home Forums Front-end Issues Show ACF group outcome on the php template


Show ACF group outcome on the php template

  • Have a problem to show the correct data, probably I miss something.
    So i created extra fields ‘Product belastingen’ with the location ‘Post type > Products’
    I created a Group > ‘belasting_laag’
    with subfields > ‘prijs’ and ‘btw’.

    I want to show this inside a PHP template.

    <?php while ( have_rows('belasting_laag', $product_id) ) : the_row(); ?>
    <?php if (get_sub_field('prijs')): ?>
    <?php the_sub_field('prijs'); ?>
    				<?php endif; ?>
    			<?php endwhile; ?>

    Why isn’t showing on the page?

  • Wow, something in your post broke the forum layout. 😮

    What about the $product_id variable? Is that necessary? If so then it’s probably also necessary on the sub fields. What happens if you do the_sub_field(‘prijs’,$product_id);

  • Ohh nooo, I’m not sure, which one, because I’m not using style, right?
    I’m not sure, can you give me an example how the code should look like, to got information from the extra field, which is implemented on the product page.
    I can’t find a good example of it.

    It is a group with two subfields on the productpage.

    Thank you.

  • The forum layout error has been fixed; supposedly it was some unclosed code tag or something like that.

    Anyway, this is what I mean:

    <?php while ( have_rows('belasting_laag', $product_id) ) : the_row(); ?>
    <?php if (get_sub_field('prijs',$product_id)): ?>
    <?php the_sub_field('prijs',$product_id); ?>
    				<?php endif; ?>
    			<?php endwhile; ?>

    Does that change anything?

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.