user1609391
user1609391

Reputation: 455

Extracting Values from Wordpress Get_Post_Meta

I am using get_post_meta($post->ID);, which returns results like the below.

I need to print to the screen the actual values for these fields wpcf-business_listing_title, wpcf-street_address, wpcf-city, etc.

How exactly do I do that? Thank you!

array(25) { 
    ["wpcf-business_listing_title"]=> array(1) {
         [0]=> string(17) "Davis Car Dealer" 
     } 
    ["wpcf-street_address"]=> array(1) { 
        [0]=> string(21) "720 Olympad Drive Ste X" 
     } 
    ["wpcf-city"]=> array(1) { 
        [0]=> string(5) "Portland" 
     } 
    ["wpcf-state_abbreviation"]=> array(1) { 
        [0]=> string(2) "ME" 
     } 
    ["wpcf-full_state_name"]=> array(1) {
        [0]=> string(10) "Maine" 
     } 
    ["wpcf-zip_code"]=> array(1) { 
        [0]=> string(5) "95616" 
     } 
    ["wpcf-county"]=> array(1) { 
        [0]=> string(4) "Yolo" 
    } 
    ["wpcf-phone_number"]=> array(1) { 
        [0]=> string(12) "555-755-3666" 
    }
}

Upvotes: 0

Views: 1996

Answers (1)

Chetan
Chetan

Reputation: 102

Here You can give the particular field slug name for example you using for wpcf-street_address then you want give like

$wpcf-street_address = get_post_meta($post->ID,'wpcf-street_address',true);

this gives you particular field value.

Upvotes: 1

Related Questions