This topic contains 1 reply and 2 voices, and was last updated by Tareq Hasan 6 years, 3 months ago
Viewing 1 Posts - 1 through 1 (of 1 total)
Author Posts
July 29, 2013 at 4:55 am 6407
Tareq Hasan I have a multicolumn repeat field that can have from zero to several entries in it. My issue is that if it has zero entries, the | seperater is still being inserted and so my display code is showing the UL container and LI label. My field is 'sources' and here's the code I'm using to display:
<?php $sources = get_post_meta( $post->ID, 'sources');
if ( $sources ) {
echo '<ul class="post-sources">';
foreach ($sources as $source) {
$values = explode( '| ', $source );
echo "<li>Source: <a href='{$values[0]}' target='_blank'>{$values[1]}</a></li>";
}
echo '</ul>';
}
?>
Thanks
July 30, 2013 at 5:56 pm 6463
Tareq Hasan Tareq Hasan

Before echo’ing the source, you might check it again
[php]
$values = explode( ‘|’, $source );

if ( $values ) {
echo "<li>Source: <a href='{$values[0]}’ target=’_blank’>{$values[1]}</a></li>";
}
[/php]

Viewing 1 Posts - 1 through 1 (of 1 total)