Hi,
I’m trying to get the post type name of posts that are fetched with the relationship field.
Example:
$post = get_sub_field('related_post');
setup_postdata($post);
$relatedLink = get_the_permalink();
$relatedPostType = get_post_type_object( $post );
$relatedPostTypeName = $relatedPostType->name;
wp_reset_postdata();
$relatedLink works fine so I know I’m getting the right post, however I get the following error while trying to display $relatedPostTypeName:
“Trying to get property of non-object in…”
The field ‘related_post” is set to be a post object. What am I missing?
Mattias
SOLVED. Of course my own mistake…