0

OK so I'm trying to use the plugin "adrotate" outside of the loop for my frontend.

I can access all the WP functions I need for everything else using

require_once(APP_PATH.BLOG_FOLDER.'wp-load.php');

The plugin has a function called adrotate_group() which is just in a script file, no class or anything.

function adrotate_group($group_ids, $fallback = 0, $weight = 0) {
    global $wpdb, $adrotate_config, $adrotate_debug;
    var_dump($adrotate_config);

This outputs NULL when I call it like so on my frontend

require_once(APP_PATH.BLOG_FOLDER.'wp-load.php');
echo adrotate_group(1);

$adrotate_config is setup in another setup script for this plugin and I've done some var_dumps there and it outputs to my frontend correctly.

Below is where the variable is set

enter image description here

For some reason using global $adrotate_config in that function isn't working, however using get_option('adrotate_config'); does, but I cannot go edit all of the plugin functions to use this as it will break on updates.

I think it has to do with the way I'm hooking wordpress.

0

OK FIXED using

define('WP_USE_THEMES', false);
require_once(APP_PATH.BLOG_FOLDER.'wp-blog-header.php');

instead of wp-load.php

Not the answer you're looking for? Browse other questions tagged or ask your own question.