Support

Account

Forum Replies Created

  • Thanks John,

    I did try having the field set to Array to start with but was not having any luck with my usual markup.

    I then tested having the field set to URL and using the example above and that worked.

    For now this is fine for me but would like to eventually get the Array image coming through for things like alt text, etc.

    Cheers.

  • Hey Wozzal, I was having the same issue and my work around for now was this was really close to your code:

    <?php // Get the taxonomy's terms
    $terms = get_terms(
        array(
            'taxonomy'   => 'news_categories',
            'hide_empty' => false,
        )
    );
    ?>
    <?php // Check if any term exists
        if ( ! empty( $terms ) && is_array( $terms ) ) {
            // Run a loop and print them all
            foreach ( $terms as $term ) { ?>
           
    
                <a href="<?php echo esc_url( get_term_link( $term ) ) ?>">
                    <?php echo $term->name; ?>
                    <?php echo the_field( 'banner_text', $term ); ?>
                    <img src="<?php echo the_field( 'banner_image', $term ); ?>">
                </a>
    
    <?php       
            }
        } 
    ?>

    Getting the Term Name and URL was easy. Getting a simple field, like a “Text Field” from ACF was straight forward too using something like:

    <?php echo the_field( 'banner_text', $term ); ?>

    I really wanted to use an array for the image but that didn’t want to work so I opted for image URL instead as my work around and just echoed this with no var:

    <img src="<?php echo the_field( 'banner_image', $term ); ?>">

    If you did ever figure out how to do this with the Image Array please let me know.
    Thanks!
    Andy

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