5

I was trying to query the database in my theme's functions.php, but it shows

Fatal error: Call to a member function get_results() on a non-object in .../functions.php

I was wondering what did I do wrong. Any help will be appreciate. Thanks.

1 Answer 1

17

try global $wpdb; before your query

Sign up to request clarification or add additional context in comments.

1 Comment

to check it, you can var_dump( $wpdb );

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.