I have seen almost all links but still I am unable to solve my problem.
I am getting $wpdb as null
.
I am checking it like this. I am doing this in single.php file
echo "<pre>";print_r($wpdb);"</pre>";
I have checked about following files. That all are loaded.
- wp-config.php
- wp-load.php
- wp-includes/wp-db.php
Please help me.
EDIT
I want to execute custom query like this.
$entries = $wpdb->get_results( $wpdb->prepare( "SELECT forms.form_title, entries. *
FROM wp_visual_form_builder_forms AS forms
INNER JOIN wp_visual_form_builder_entries AS entries ON entries.form_id = forms.form_id" ) );
this is not working.
If you read the documentation, you will notice this passage:
It's not very clear but I think that means you cannot use
$wpdb
outside of a function. What I recommend you do is create a function in your theme'sfunctions.php
file, and call that function from the single.php file.