Home Forums Plugin Support WP User Frontend Pro Multicolumn Repeat Field Issue

This topic is: not resolved

Tagged: ,

This topic contains 1 reply, has 2 voices, and was last updated by  Tareq Hasan 5 years, 6 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #6407

    djhaystack
    Participant
    Post count: 2

    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

    #6463

    Tareq Hasan
    Keymaster
    Post count: 2831

    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 2 posts - 1 through 2 (of 2 total)

The topic ‘Multicolumn Repeat Field Issue’ is closed to new replies.