在插件模板中访问帖子ID

I want to pass a custom parameter from an ACF Field to a function in a wordpress plugin (https://wordpress.org/plugins/insta-gallery/).

When I declare the variable globally in my functions.php it works fine but the problem I am having is that I need a post ID for me to get the ACF Field Variable.

When I retrieve the the post ID inside the WP loop and before the content is printed and call the function that retrieves that variable inside the plugin file (in order to get the ID), I get an error.

I somehow need to get the post ID from inside the php file of the plugin.

The order the code is executed is as follows: 1. Custom Code written Template.php File with ACF 2. At the end Template.php file fetches Wordpress Content 3. Inside the Wordpress Content there's a shortcode of the plugin 4. Plugin's shortcode is executed (in best case with my parameter from ACF field)

Would something like this work for you?

function inside_content() {
    global $post;
    your_plugin_function($post->ID);
}

add_action( 'the_content', 'inside_content' );