/ Published in: PHP
Gets all of a Wordpress post meta data in an array without specifying a key
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
function get_post_meta_all($post_id){ global $wpdb; $wpdb->query(" SELECT `meta_key`, `meta_value` FROM $wpdb->postmeta WHERE `post_id` = $post_id "); foreach($wpdb->last_result as $k => $v){ $data[$v->meta_key] = $v->meta_value; }; return $data; }