I forgot to say that, I got displayed selected attachment in admin side. The error only occurs when I select Elements
setting in Custom Field setting.
I got the solution. It’s very simple.
$logo = get_field('field_53368dabb411e', 'manufacturer_'.$m->term_id);
As documentation says that we can pass POST ID
as second argument, This can also be options / taxonomies / users / etc.
Now I have to work with custom taxonomy. So if I pass taxonomy term id as second parameter, it doesn’t work. It search value in wp_postmeta
table, which is wrong. Because ACF didn’t store taxonomy/relationship field data in wp_postmeta
table. It stores in wp_options
table.
So now problem is how to pass argument that ACF get actual value. I search all code related to relationship field and how ACF insert & get data from DB. I just concat the taxonomy slug
+ ‘_’ + taxonomy term id
and I got my result.
I don’t know whether this is bug is plugin or they forgot to update or mention in documentation, but I got my desired result with this hack.
I see you figured out your answer but the bug still remains from what I can see. When I add custom post type relationship field to an options page right now I’m getting that same notice:
Notice: Trying to get property of non-object in \acf\core\fields\relationship.php on line 496
Any thoughts on how this should resolved?
Also getting this issue. For me it’s when I’m using the relationship field on a custom options page.
$p
as defined on line 492 is the post object for the field we are trying to retrieve, which means the fix should be as simple as passing that into get_post_type
right? – like so:
$post_type_object = get_post_type_object( get_post_type( $p ) );
If you require assistance then, as per the Forum Welcome, please post your own topic instead of tagging onto someone else’s topic.
I am now closing this 2 month old resolved topic as it references an older version of WordPress.