PHP code snippets Critical Error

I use a PHP code snippet to display a download link for the ACF plugin, however when I activate this plugin i get a critical error. The backend page shows the following message:

“INSERT PHP CODE SNIPPET caused a fatal error and has been deactivated in the FDP backend pages.”

The error specifically reads:

Uncaught Error: Call to undefined function get_field() in wp-content/plugins/insert-php-code-snippet/shortcode-handler.php(99) : eval()'d code:2 Stack trace: #0 wp-content/plugins/insert-php-code-snippet/shortcode-handler.php(99): eval() #1 wp-includes/shortcodes.php(355): xyz_ips_display_content(Array, '', 'xyz-ips') #2 [internal function]: do_shortcode_tag(Array) #3 wp-includes/shortcodes.php(227): preg_replace_callback('/\\[(\\[?)(xyz\\-i...', 'do_shortcode_ta...', '[xyz-ips snippe...') #4 wp-content/plugins/elementor-pro/modules/dynamic-tags/tags/shortcode.php(54): do_shortcode('[xyz-ips snippe...') #5 wp-content/plugins/elementor/core/dynamic-tags/tag.php(35): ElementorPro\Modules\DynamicTags\Tags\Shortcode->render() #6 /home/otterbhouse/staging

Just if it is any interest, the snippet in question is the following:

<?php
$file = get_field('menu_file', 402);
if( $file ): ?>
    <?php echo $file['url']; ?>
<?php endif; ?>

I have had to deactivate the plugin so the functionality on my site still works. Is there anyway to stop it checking for errors/ even leave this page alone completely as I can assure I have absolutely no errors when I don’t have this plugin deactivated.

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer