Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

can not call $wpdb in functions.php in wordpress

Tags:

wordpress

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.

like image 766
Wen Avatar asked Apr 09 '12 16:04

Wen


1 Answers

try global $wpdb; before your query

like image 78
Rob Avatar answered Sep 28 '22 00:09

Rob