Support

Account

Home Forums Front-end Issues Returning Custom Field Values (including Taxonomy Terms) on Term archive pages Reply To: Returning Custom Field Values (including Taxonomy Terms) on Term archive pages

  • @hube2: I’m able to now retrieve an array with:

    <?php
    $queried_object = get_queried_object();
    $taxonomy = $queried_object->taxonomy;
    $term_id = $queried_object->term_id;
    
    $value = get_field( 'test_field', $taxonomy.'_'.$term_id);
    if( $value ) {
        echo $value;
    } else {
        echo 'empty';
    }
    ?>

    Why cant the_field() do what echo does here?

    I retrieve an array when the custom field is text & get an error message when its a taxonomy term:

    “Catchable fatal error: Object of class WP_Term could not be converted to string”

    I also retrieve an array when the custom field is an image.

    Looks like we now have to iterate through the string array in order to show the value; brings back the 2nd aspect of my question.

    How do you best display the returned string(s)/array on a taxonomy term archive page:
    -if ACF field value is text?
    -if ACF field value is an image?
    -if ACF field value is a single or multiple taxonomy terms?
    -if I would like to display the term values as linkable vs non linkable?