Support

Account

Home Forums General Issues Get term names and ACF fields in loop

Unread

Get term names and ACF fields in loop

  • Hey there,

    Figured this would be pretty easy but I am running into an issue.

    The website I am building, the client has a list of taxonomies that have an ACF Image Field and ACF Description field.

    What they want to do is have a block where they can select certain ingredients from the Taxonomy Block, then have it render out formatted (At this time it doesnt need to link to the actual category) but they want to do it this way so they dont need to update page by page when an ingredient changes description or image they can just change it in the taxonomy list.

    I can get it to print ID’s but it refuses to print name or anything else

    <?php
    $terms = get_field('ingredients_selector');
    if( $terms ): ?>
    <ul>
    <?php foreach( $terms as $term ): ?>
    <li>
    <h2><?php echo esc_html( $term->name ); ?></h2>
    <p>Term description: <?php the_field('description', $term); ?></p>
    <p>Term Image: <?php the_field('image', $term); ?></p>
    <p><?php echo esc_html( $term->description ); ?></p>
    <a href="<?php echo esc_url( get_term_link( $term ) ); ?>">View all '<?php echo esc_html( $term->name ); ?>' posts</a>
    </li>
    <?php endforeach; ?>
    </ul>

    <?php endif; ?>

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.