Tell me more ×
WordPress Answers is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I created a wordpress plugin with a shortcode. I am just wondering why the content in the shortcode does not show after calling $wpdb->get_results();

Below is the code:

$query = "SELECT * FROM table WHERE field='$var' ORDER BY field2 ASC";

//return 'test'; //this one works...

$results = $wpdb->get_results($query);

if($results === false)
    return 'error occured'; //wont work or display

if(count($results) > 0)
    return 'has results'; //wont work or display also..
else
    return 'no results found' //wont work or display also..

The query was okay because I returned it before calling the function then test in mysql, and there are results. Now what is going on here?

Thanks..

share|improve this question
1  
Do you declare $wpdb as a global at any point? – m0r7if3r Mar 6 '12 at 11:24
Use WP_DEBUG_QUERIES set to true in your wp-config.php – kaiser Mar 7 '12 at 9:35

closed as not a real question by toscho Mar 6 at 23:41

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, see the FAQ.

Browse other questions tagged or ask your own question.