<?php
// False: get all, true: get only first
// Use false if you want to get all, if you have only one, it doesn't break
$profile_twitter = get_post_meta( $post->ID, 'profiletwitter', false );
// Let's check if there's any
if( ! empty( $profile_twitter ) ) { ?>
<span class="social-profile"> <?php
// Check if an array -> has more than one
if( is_array( $profile_twitter ) ) {
// Loop through each twitter url
foreach( $profile_twitter as $single_twitter ) { ?>
<a href="https://wordpress.stackexchange.com/questions/225956/<?php echo $single_twitter; ?>" target="blank">
<img src="http://blogomanija.net/sajt/wp-content/themes/blogomanija/images/social/twitter-small.png" />
</a> <?php
}
}
// Not an array, it must be single (if it's correctly stored in db)
else { ?>
<a href="<?php echo $profile_twitter; ?>" target="blank">
<img src="http://blogomanija.net/sajt/wp-content/themes/blogomanija/images/social/twitter-small.png" />
</a> <?php
} ?>
</span> <?php
} ?>
More reading: