简体   繁体   中英

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" 
    }
}

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM