CyberShot Posted August 27, 2011 Share Posted August 27, 2011 I am working with wordpress. I am coding some custom meta boxes following some code someone else had written. My code is working but I am not sure if I need to do it the way I am doing it. The person who wrote the code added the option like so $custom = get_post_meta($post->ID); $item_link = $custom["item_link"][0]; According to the wordpress codex, get_post_meta($post->ID) Returns a multidimensional array with all custom fields of a particular post or page. so when I added a second option, I followed with this $item_text = $custom["item_text"][0]; I guess my question would be..Do i need to add the index 0 to every option or should I increase it by 1 for every new option I add? Link to comment https://forums.phpfreaks.com/topic/245805-explain-this-array-please/ Share on other sites More sharing options...
jcbones Posted August 27, 2011 Share Posted August 27, 2011 Welp, I don't know wordpress, but I would suggest a little de-bugging. $custom = get_post_meta($post->ID); echo '<pre>' . print_r($custom,true) . '</pre>'; $item_link = $custom["item_link"][0]; Link to comment https://forums.phpfreaks.com/topic/245805-explain-this-array-please/#findComment-1262704 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.