andriuss
Member
Posted 1 year ago #
Hello,
I have serious problem. When I want to load function wp_handle_upload in my theme functions.php file. It shows me error: Fatal error: Call to undefined function wp_handle_upload() in C:\xampp\htdocs\thisblog\wp-content\themes\geektheme\functions.php on line 150
Why I get it in my theme ? Maybe I need to add any global word ?
Thank you.
andriuss
Member
Posted 1 year ago #
Hi,
It's because the function is meant to be used on a plugin, not a theme.
Try including those files before the call:
include_once($_SERVER['DOCUMENT_ROOT'].'wp-admin/includes/media.php');
include_once($_SERVER['DOCUMENT_ROOT'].'wp-admin/includes/file.php');
include_once($_SERVER['DOCUMENT_ROOT'].'wp-admin/includes/image.php');
Better this way:
include_once ABSPATH . 'wp-admin/includes/media.php';
include_once ABSPATH . 'wp-admin/includes/file.php';
include_once ABSPATH . 'wp-admin/includes/image.php';