So as described in the docs, the get_field
function will try to get the post id
that your field is associated. If he can’t it will return nothing, so you have to pass the post id
yourself, like the example below that I got in the docs:
$post_id = false; // current post
$post_id = 1; // post ID = 1
$post_id = "user_2"; // user ID = 2
$post_id = "category_3"; // category term ID = 3
$post_id = "event_4"; // event (custom taxonomy) term ID = 4
$post_id = "option"; // options page
$post_id = "options"; // same as above
$value = get_field( 'my_field', $post_id );
To learn more about see in the Docs.