Posted By

web_la on 11/22/13


Tagged

wordpress


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

fhenderson


Get all Wordpress post meta


 / Published in: PHP
 

Gets all of a Wordpress post meta data in an array without specifying a key

  1. function get_post_meta_all($post_id){
  2. global $wpdb;
  3. $data = array();
  4. $wpdb->query("
  5. SELECT `meta_key`, `meta_value`
  6. FROM $wpdb->postmeta
  7. WHERE `post_id` = $post_id
  8. ");
  9. foreach($wpdb->last_result as $k => $v){
  10. $data[$v->meta_key] = $v->meta_value;
  11. };
  12. return $data;
  13. }

Report this snippet  

You need to login to post a comment.