Return to Snippet

Revision: 65351
at November 22, 2013 02:13 by web_la


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 of a Wordpress post meta data in an array without specifying a key

Initial Title
Get all Wordpress post meta

Initial Tags
wordpress

Initial Language
PHP