Home Forums ACF PRO Display ACF field's Taxonomy in Custom Post Type


Display ACF field's Taxonomy in Custom Post Type

  • Hi there,
    I would like to display an ACF link from Custom Taxonomy to Custom Post Type’archive. In fact I want to replace the taxonomy’s link with another ACF link, only for CPT.

    This is my situation:
    1- I have the ACF link inside Custom Taxonomy.
    2- I have the archive with loop of CPT.
    3- This is the loop, where $term_link should be replaced with ACF link.

    <?php if ( have_posts() ) : ?>
    <?php while ( have_posts() ) : the_post(); ?>
    <div <?php post_class(); ?> id="post-<?php the_ID(); ?>">
    <?php $terms = get_the_terms( $post->ID , 'name_taxonomy' );
    foreach ( $terms as $term ) {
    $term_link = get_term_link( $term, 'name_taxonomy' );
    if( is_wp_error( $term_link ) )
    echo '<a href="' . $term_link . '">' . $term->name . '</a>';
    <?php endwhile; ?>
    <?php wp_reset_postdata(); ?>
    <?php endif; ?>

    Any suggests? Thank you so much!

    $term_link = get_field('link-field-name', $term);
  • Thank you John!

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

You must be logged in to reply to this topic.

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.