I’m having issues outputting the value of a
$wpdbquery that I’ve written. The SQL is successful. A
print_r()will output the correct values, but now I have to output them in a loop (and all the commensurate functions that become available within it), and for the life of me, I can’t seem to get this working. I have called
global $wpdb;at the top of my document.
$sql_get_posts = " SELECT *** Big multi-join, multi-criteria but fully functional SQL query *** "; // Run the query and set it to a variable $sql_query = $wpdb->get_results($wpdb->prepare( $sql_get_posts)); print_r($sql_query);
This seems to output my values correctly.
$the_search_results = query_posts($sql_query);which in theory feeds my loop does not. I suspect that it is because this is expecting
I am using
while ( have_posts() ) : the_post();so that I can use things like
get_permalink( $post->ID )and
What am I doing wrong? What should I be doing to avail myself of my query results?
- The topic ‘Trouble getting $wpdb to output’ is closed to new replies.