Search code examples
phpwordpressfatal-error

Wordpress - PHP Fatal error: Call to undefined function get_bloginfo()


I'm integrating an external script with my wordpress theme and I'm getting this error in one of my files:

PHP Fatal error: Call to undefined function get_bloginfo()

this script is located in

themes/mytheme/myscript

And all files are included as following:

include(WP_CONTENT_DIR."/themes/mytheme/myscript/myfile.php");

how can I fix it?


Solution

  • you must include wp-blog-header.php in your main php like this

    require WP_DIR.'/wp-blog-header.php';
    

    being WP_DIR the main wp directory