i have problem with using function/events of WP in external file.
Here is a code example:
<?php
ini_set('display_startup_errors',1);
ini_set('display_errors',1);
error_reporting(-1);
define('THEME_ROOT', dirname(dirname(__FILE__)));
define ('WP_ROOT', dirname(dirname(dirname(THEME_ROOT))));
// Include WP
require( WP_ROOT . '/wp-blog-header.php' );
// Include Autoloader
require_once(THEME_ROOT . '/vendor/autoload.php');
function crazyLoaded() {
echo 'Hello WP';
}
add_action('wp_loaded', 'crazyLoaded');
$imagePost = media_handle_sideload(array('<siteroot>'.$data['Venue.image']),0);
Function crazyLoaded() is not calling at all and call media_handle_sideload() is leading to Fatal Error “Unknown Function” while wp_insert_post()/wp_insert_term() and other “wp_” functions are working correctly.
What am i doing wrong?
Thanks.
Including
Saved the day.