Posted By

mattkenefick on 10/12/10


Tagged

get data wordpress meta


Versions (?)

Who likes this?

3 people have marked this snippet as a favorite

mfgalex
hariom
rabc


Wordpress | Get All Meta Data


 / Published in: PHP
 

Gets all meta data keys/values for a particular post

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

Report this snippet  

You need to login to post a comment.