Home Forums Front-end Issues Trying to get property of non-object (ACF 5.8.5)


Trying to get property of non-object (ACF 5.8.5)

  • Hi
    I’m have read a document field taxonomy basic display (single value)
    $term = get_field(‘taxonomy_field_name’);
    <?php echo $term->name; ?>
    but when done error “Trying to get property ‘name’ of non-object”.
    I have tried to search on google but it still does not work, has anyone ever encountered this error please just help

  • Hi there,

    I think you just have to echo your $term only.

    <?php echo $term; ?>

    When you register a relashionship field (taxonomy), you have an option called “returning value”.
    By default, this field return an “ID value”.

    If you want to use several properties of your taxonomy (like description and title), you have to check the returning value as an Object.

    Then you target the right property (name, description etc…)

    Let me know if it helps,


  • This kind of error is very common but not specific to ACF. You’re trying to echo $term->name, and the error says it can’t find name. So take a step back and see what WordPress has actually put into your $term by dumping it. You can’t echo every type of var, but you can print_r() it. Do a print_r( $term ); and go from there. It may be empty, it may be a string, array, object. Lots of possibilities.

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

The topic ‘Trying to get property of non-object (ACF 5.8.5)’ is closed to new replies.