How can I get post meta data (custom field) from within a custom wordpress action hook?

I have a custom hook in my theme which is set up like this:


That code is in my header.php file and outside of the main loop.

I have a call to this hook like so in my functions.php file:

if( !function_exists( 'my_function' )){
    function my_function() {
        //to be run before the featured overlay (outside)
        echo do_shortcode('[my_shortcode]');

This is my shortcode:

function my_shortcode_function(){
    echo get_field('test');
add_shortcode( 'my_shortcode', 'my_shortcode_function' );

Is there some way I should set up my do_action(); differently so that it has the current post object available, or do I need to put a loop inside of my function to get it to work? I am just looking for advice on how would be best to accomplish this.