Return to Snippet

Revision: 33686
at October 12, 2010 05:58 by mattkenefick


Initial Code
function get_post_meta_all($post_id){
    global $wpdb;

    $data   =   array();

    $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;
}

Initial URL

                                

Initial Description
Gets all meta data keys/values for a particular post

Initial Title
Wordpress | Get All Meta Data

Initial Tags
data, wordpress

Initial Language
PHP