Wrap Meta Box with
  • and
  • for each new line

    Question

    I’m trying to automate one of our posting aspects. We post a lot of lyrics and have a system of meta boxes which we use to input various pieces of information about each set of lyrics we post. One aspect that is a little annoying is having to search & replace <li></li>tags to the start and end of each new line of lyrics. I was hoping to have PHP echo this automatically but my code is not working at the moment.
    Here is my untouched code which outputs a verse of lyrics (we use wpautopso that line breaks are respected):

    <?php if ( get_post_meta($post->ID, '_cmb_lyrics_1', true) ) : ?>
    <?php $lyrics_1 = get_post_meta($post->ID, '_cmb_lyrics_1', true) ?>
    <ul>
    <?php echo wpautop( $lyrics_1) ; ?>
    </ul>
    <?php endif; ?> 
    

    And here is my attempt at outputting <li>tags, which didn’t work. 🙁

    <?php if ( get_post_meta($post->ID, '_cmb_lyrics_1', true) ) : ?>
    <?php $lyrics_1 = get_post_meta($post->ID, '_cmb_lyrics_1', true) ?>
    <ul>
    <?php 
    echo "<li>n"; wpautop( $lyrics_1) ; "</li>n"; ?>
    </ul>
    <?php endif; ?>
    

    Any help appreciated. Thanks.

    0
    , JMB 9 years 2013-02-14T04:55:31-05:00 0 Answers 91 views 0

    Leave an answer

    Browse
    Browse