Search code examples
wordpressscheduled-tasksadvanced-custom-fieldsplesk

Undefines function get_field() on PLESK Schedulation Tasks


I'm trying to create a schedule script php from PLESK but i have a problem when i've use get_field() function from ACF. Plesk retriew the error: " PHP Fatal error: Uncaught Error: Call to undefined function get_field()..... "

I have the same problem with all function called from Wordpress.

The code inside the PHP script is:

    $my_var = get_field('indirizzo_ip','options');
    echo $my_var;

Can someone help me?

Thanks


Solution

  • Include these files at the top of your script and you`ll have all the WordPress functions available:

    define('WP_USE_THEMES', false);
    require('/path/to/your/httpdocs/wp-blog-header.php');
    require('/path/to/your/httpdocs/wp-admin/includes/admin.php');
    

    Regards Tom