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
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)
You must be logged in to reply to this topic.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users