I am trying to retrieve the post ID of a related post connected through a specific Toolset Post Reference Field in PHP, but using get_post_meta() returns an empty string, and I need to avoid fetching all related posts of the same type.
Solution:
Use toolset_get_related_post( $post_id, 'relationship-slug' ) to retrieve the post ID tied specifically to the Post Reference Field; it returns the related post ID or 0 if none is found.
Example:
$related_post_id = toolset_get_related_post( 123, 'advisor' );
if ( $related_post_id ) {
echo 'Related post ID: ' . $related_post_id;
} else {
echo 'No related post found.';
}