You can use what you have with slight modification. Just increase the height of the meta box and let your users enter an item on each line.
Embed
$recipe_embed = get_post_meta( $post->ID, "recipe_embed", true );
if ( ! empty( $recipe_embed ) ): ?>
<div style="background: green;">
<?php
// normalize returns
$recipe_embed = str_replace( "\n", "\r", $recipe_embed );
// convert to array and remove empty items
$ingredients = array_filter( explode( "\r", $recipe_embed ) );
// list items
echo "<ul class="ingredients">";
foreach ( $ingredients as $ingredient ) {
echo "<li class="ingredient" >$ingredient</li>";
}
echo "</ul>";
?>
</div>
<?php endif; // $recipe_embed
Meta Box
<?php
function add_embed_recipe_meta_box() {
add_meta_box( 'embed_recipe_meta_box', // $id
'Recipe Post meta box', // $title
'show_embed_recipe_meta_box', // $callback
'post', // $page
'normal', // $context
'high' );
}
add_action( "add_meta_boxes", "add_embed_recipe_meta_box" );
function show_embed_recipe_meta_box( $post ) {
$meta = get_post_meta( $post->ID, 'recipe_embed', true );
wp_nonce_field( basename( __FILE__ ), "recipe-meta-box-nonce" );
?>
<table class="form-table">
<tr>
<th><label for="recipe_embed">Ingredients</label></th>
<td><textarea name="recipe_embed" id="recipe_embed" cols="60" rows="10"><?php echo $meta; ?></textarea></td>
</tr>
</table>
<?php
}
function save_recipe_embed( $post_id, $post, $update ) {
if ( ! isset( $_POST[ "recipe-meta-box-nonce" ] ) || ! wp_verify_nonce( $_POST[ "recipe-meta-box-nonce" ], basename( __FILE__ ) ) ) {
return $post_id;
}
if ( ! current_user_can( "edit_post", $post_id ) ) {
return $post_id;
}
if ( defined( "DOING_AUTOSAVE" ) && DOING_AUTOSAVE ) {
return $post_id;
}
$slug = "post";
if ( $slug != $post->post_type ) {
return $post_id;
}
$recipe_embed = '';
if ( isset( $_POST[ "recipe_embed" ] ) ) {
$recipe_embed = $_POST[ "recipe_embed" ];
}
update_post_meta( $post_id, "recipe_embed", $recipe_embed );
}
add_action( "save_post", "save_recipe_embed", 10, 3 );