Inspiration For Creative Minds
Home » Labs » How to get all post meta from WordPress  

Filed under Labs

Add below set of code to your functions.php and call it in theme where you want to show meta data.

function get-post_meta($post_id){
    global $wpdb;
    $data   =   array();
        SELECT `meta_key`, `meta_value`
        FROM $wpdb->postmeta
        WHERE `post_id` = $post_id
    foreach($wpdb->last_result as $x => $y){
        $data[$y->meta_key] =   $y->meta_value;
    return $data;
It's only fair to share...Share on Google+Tweet about this on TwitterShare on Facebook

Posts you may like: