Support

Account

Home Forums General Issues Cant get_field taxonomy->name

Helping

Cant get_field taxonomy->name

  • ey 🙂

    Im trying to get the object name but it wont show anything an can get the array by using this code

    <pre><?php print_r(get_field('udvikler')); ?></pre>

    and the output i get from it is this

    Array
    (
        [0] => stdClass Object
            (
                [term_id] => 21
                [name] => IO Interactive
                [slug] => io-interactive
                [term_group] => 0
                [term_taxonomy_id] => 4374
                [taxonomy] => udvikler
                [description] => 
                [parent] => 0
                [count] => 1
                [object_id] => 59429
                [filter] => raw
            )
    
    )

    and i want to get the name how do i do that

    Also i so its properly checked more than once it should be in a foreach and print it

    How to i do this

  • 
    $terms = get_field('udvikler');
    echo $terms[0]->name;
    

    or more likely since you’re getting an array

    
    $terms = get_field('udvikler');
    if (count($terms)) {
      foreach ($terms as $term) {
        echo $term->name,'<br />';
      }
    }
    
Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.