I'm sure this is a fairly basic question but I can't seem to get it right.
I have multiple custom field values for addresses in my custom post type and I want to save them as a single value or array so I can display them in one call rather than many. I would also like to output the address comma separated, but first need to preg replace any commas entered by the user in the wordpress backend so I don't end up with, for example, '10 high street,, London,, W11 1TT'
I have this currently:
<?php global $post; $address_name = get_post_meta( $post->ID, '_mfl_entry_address_name', true ); $address_street = get_post_meta( $post->ID, '_mfl_entry_address_street', true ); $address_line_2 = get_post_meta( $post->ID, '_mfl_entry_address_line_2', true ); $address_line_3 = get_post_meta( $post->ID, '_mfl_entry_address_line_3', true ); $address_postcode = get_post_meta( $post->ID, '_mfl_entry_address_postcode', true ); ?>
How would I put these into a single value called 'address', clean out any commas added by the user, then output the address with each value separated by a comma, except the last one?
Thanks for any help