Wrap Meta Box with and for each new line
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 wpautop
so 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.
Leave an answer