0

The code below comes from:

var_dump(get_post_custom($post->ID)). 

How can I echo the value of artist_seo_description from my PHP script?

array(5) { ["_edit_last"]=> array(1) { [0]=> string(1) "1" } ["_edit_lock"]=> array(1) { [0]=> string(12) "1425587233:1" } ["photo-artist_tfuse_post_options"]=> array(1) { [0]=> string(1182) "a:4:{s:25:"photo-artist_slider_image";s:0:"";s:28:"photo-artist_slides_interval";s:4:"6000";s:22:"photo-artist_seo_title";s:21:"Crest Drive Residence";s:28:"photo-artist_seo_description";s:985:"This is the description field.";}" } ["_wp_old_slug"]=> array(1) { [0]=> string(22) "crest-drive-renovation" } ["photo-artist_post_viewed"]=> array(1) { [0]=> string(1) "0" } }
  • do you mean photo-artist_seo_description? it's saved under the key photo-artist_tfuse_post_options. – Milo Mar 5 '15 at 22:31
  • Yes. How can I grab that value from the key? – Scott B Mar 5 '15 at 22:33
1

get_post_custom isn't a great function if you're trying to get values that are serialized, you have to unserialize them yourself.

A better function is get_post_meta:

$options = get_post_meta( $post->ID, 'photo-artist_tfuse_post_options', true );
echo $options['photo-artist_seo_description'];

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.