So I'm using $wpdb->get_results() to query my database and then make AJAX call from JS file. The problem is that I need to get the value itself, like a string, instead of array, but as much as I know, get_results return only array. Is there any way around this to get string value from database? Or should I use something else than get_results()?

  • Why not use that array and get the string from it?
    – kero
    Commented Nov 13, 2018 at 17:32
  • I converted it to JSON but still don't know how to access the string in the loop. I have an array of json objects here. Any hints?
    – Limpuls
    Commented Nov 13, 2018 at 17:55

1 Answer 1


$wpdb->get_results() only returns arrays( associative or numeric) or an object. It does not return a string value.

If you want a string value, you need to use $wpdb->get_var() instead

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.