I wrote a function which should give you the value of a meta key for all of the posts. I am not sure why my query is not working. It gives me an empty array
as output when I var_dump
the query. The value of the meta key is stored in array
, so I am using unserialize
to convert the mysql array to PHP array.
The Function
function wp_postquiz_total_completed_quizes_by_user( ) {
global $wpdb;
$mylink = $wpdb->get_results("
SELECT $wpdb->postmeta.meta_value *
FROM $wpdb->postmeta
WHERE $wpdb->postmeta.meta_key = '_pq_users_answered_quiz_on_post'",
ARRAY_A);
$array = unserialize($mylink);
return $array;
}