Skip to main content

I'm either being daft or just having huge trouble with something that I think should be easier than I'm making it, I am echoing thumbnails for a list of items within a 'Show' custom taxonomy. Within this taxonomy I have additional fields via Advanced Custom Fields / ACF:

'podcast_category_thumb' = image field 'podcast_topic' = Taxonomy field linked to another custom taxonomy.

'podcast_category_thumb' = image field
'podcast_topic' = Taxonomy field linked to another custom taxonomy.

Using the code below I can output the image just fine. But where I have "echo get_field('podcast_topic', $term);" I

echo get_field('podcast_topic', $term);

"I simply receive "ARRAY".

I guess it's because it's a taxonomy field with multiple values(?) What I'm hoping for is just an echo of the 'podcast_topic' content. I've googled this like crazy but I can't seem to find a way to achieve this without a foreach to list each item, but since I'm already within a foreach there doesn't seem to be any way to do it.

Am I daft and/or missing something obvious, or is there a better way to handle this??

    <?php 
        if( get_terms('shows') )
        {
            foreach( get_terms('shows') as $term )
            {
                    echo '<div class="item ';
                    echo get_field('podcast_topic', $term);
                    echo ' col-4 col-md-3 col-lg-2"><a href="/shows/';
                    echo $term->slug;
                    echo '">';
                    echo wp_get_attachment_image( get_field('podcast_category_thumb', $term), 'thumbnail', false);
                    echo '</a></div>';
            }
        }
     ?>

I'm either being daft or just having huge trouble with something that I think should be easier than I'm making it, I am echoing thumbnails for a list of items within a 'Show' custom taxonomy. Within this taxonomy I have additional fields via Advanced Custom Fields / ACF:

'podcast_category_thumb' = image field 'podcast_topic' = Taxonomy field linked to another custom taxonomy.

Using the code below I can output the image just fine. But where I have "echo get_field('podcast_topic', $term);" I simply receive "ARRAY".

I guess it's because it's a taxonomy field with multiple values(?) What I'm hoping for is just an echo of the 'podcast_topic' content. I've googled this like crazy but I can't seem to find a way to achieve this without a foreach to list each item, but since I'm already within a foreach there doesn't seem to be any way to do it.

Am I daft and/or missing something obvious, or is there a better way to handle this??

    <?php 
        if( get_terms('shows') )
        {
            foreach( get_terms('shows') as $term )
            {
                    echo '<div class="item ';
                    echo get_field('podcast_topic', $term);
                    echo ' col-4 col-md-3 col-lg-2"><a href="/shows/';
                    echo $term->slug;
                    echo '">';
                    echo wp_get_attachment_image( get_field('podcast_category_thumb', $term), 'thumbnail', false);
                    echo '</a></div>';
            }
        }
     ?>

I am echoing thumbnails for a list of items within a 'Show' custom taxonomy. Within this taxonomy I have additional fields via Advanced Custom Fields / ACF:

'podcast_category_thumb' = image field
'podcast_topic' = Taxonomy field linked to another custom taxonomy.

Using the code below I can output the image just fine. But where I have

echo get_field('podcast_topic', $term);

"I simply receive "ARRAY".

I guess it's because it's a taxonomy field with multiple values(?) What I'm hoping for is just an echo of the 'podcast_topic' content. I've googled this like crazy but I can't seem to find a way to achieve this without a foreach to list each item, but since I'm already within a foreach there doesn't seem to be any way to do it.

Am I daft and/or missing something obvious, or is there a better way to handle this??

    <?php 
        if( get_terms('shows') )
        {
            foreach( get_terms('shows') as $term )
            {
                    echo '<div class="item ';
                    echo get_field('podcast_topic', $term);
                    echo ' col-4 col-md-3 col-lg-2"><a href="/shows/';
                    echo $term->slug;
                    echo '">';
                    echo wp_get_attachment_image( get_field('podcast_category_thumb', $term), 'thumbnail', false);
                    echo '</a></div>';
            }
        }
     ?>
Source Link
tch
  • 3
  • 5

Echo ACF taxonomy field within a foreach for another taxonomy

I'm either being daft or just having huge trouble with something that I think should be easier than I'm making it, I am echoing thumbnails for a list of items within a 'Show' custom taxonomy. Within this taxonomy I have additional fields via Advanced Custom Fields / ACF:

'podcast_category_thumb' = image field 'podcast_topic' = Taxonomy field linked to another custom taxonomy.

Using the code below I can output the image just fine. But where I have "echo get_field('podcast_topic', $term);" I simply receive "ARRAY".

I guess it's because it's a taxonomy field with multiple values(?) What I'm hoping for is just an echo of the 'podcast_topic' content. I've googled this like crazy but I can't seem to find a way to achieve this without a foreach to list each item, but since I'm already within a foreach there doesn't seem to be any way to do it.

Am I daft and/or missing something obvious, or is there a better way to handle this??

    <?php 
        if( get_terms('shows') )
        {
            foreach( get_terms('shows') as $term )
            {
                    echo '<div class="item ';
                    echo get_field('podcast_topic', $term);
                    echo ' col-4 col-md-3 col-lg-2"><a href="/shows/';
                    echo $term->slug;
                    echo '">';
                    echo wp_get_attachment_image( get_field('podcast_category_thumb', $term), 'thumbnail', false);
                    echo '</a></div>';
            }
        }
     ?>