You may be seeing an error like this:
[php]
Fatal error: Call to a member function get_var() on a non-object…
Fatal error: Call to a member function get_var() on a non-object…
Fatal error: Call to a member function get_var() on a non-object…
Fatal error: Call to a member function get_var() on a non-object…
[/php]
Super scary, huh? Well, it’s also super easy to solve!
You probably just forgot to call the {php}$wpdb{/php} object into your PHP. Just add {php}global $wpdb;{/php} at the beginning of your function and you should be off to the races.
[php]
add_action(‘wp_footer’, ‘my_function’);
function my_function() {
global $wpdb;
// the rest of the function
}
[/php]
Share/Ask