Fatal error: Call to a member function get_var() on a non-object in – Solved

I was writing a WordPress plugin and encountered an error saying:

Fatal error: Call to a member function get_var() on a non-object in ……. on line ….

The code was clear and short and didn’t have any such bugs to cause fatal errors.

However, there was something missing which caused this error.

To solve this error, simply add this line of code above / in between your code where necessary:

global $wpdb;

This shouldn’t trigger the Fatal error: Call to a member function get_var() on a non-object in … on line … again.

hire best wordpress php css developer
Need Help? Hire me now!
I can help you in anything related to webdevelopment, including: HTML, CSS, PHP & MySql, WordPress (plugins & themes development, others), regular expressions, server management, etc.

Leave a Reply

Your email address will not be published.