Multiple custom fields with the same name

Yes, it’s possible to have multiple fields with the same key.

When using get_post_meta($post_id, $key, $single), make sure you set the $single parameter to false (or just leave it off since it defaults to false).

get_post_meta( $post->ID, 'Event Promotion', false )

or

get_post_meta( $post->ID, 'Event Promotion' )

This will return an array containing every value of the key (what you’re expecting). If you set $single to true it will return the first value of the specified key as a string (what you’re currently getting).

References:

http://codex.wordpress.org/Custom_Fields

http://codex.wordpress.org/Function_Reference/get_post_meta

Leave a Comment