0

I have multiple values I need to be able to punch into a meta-box on the post edit screen.

EX: I am working with set-list information for concerts.

  1. Song 1
  2. Song 2
  3. Song 3

etc...

I am always looking for efficiency in my code, here's the point:

Do I just create a brand new id (i.e. song_1, song_2) for every song. Or is there a more condensed way to go about this. Here's a sample of how I would do it as of right now... which would seem like a lot of unncessary code, but then again I am not certain.

<?php   
include('preset-library.php');

$meta_box['post'] = array(

// default values, will change to more descriptive values later

    'id' => 'post-format-meta',  
    'title' => 'Additional Post Format Meta',    
    'context' => 'normal',           
    'priority' => 'high',
    'fields' => array(
        array(
            'name' => 'Song 1',
            'desc' => 'Setlist Song 1',
            'id' => 'song_1',
            'type' => 'text',
            'default' => ''
        ),
        array(
            'name' => 'Song 2',
            'desc' => 'Setlist Song 2',
            'id' => 'song_2',
            'type' => 'text',
            'default' => ''

// then additional songs 

        )
    )
);
add_action('admin_menu', 'plib_add_box');
?>
1

I believe that your best option would be to create a single field and save all values in an array, something like this: Create more Meta Boxes as needed.

0

You could look at adding a custom select meta box for the songs instead of just having multiple text boxes.

http://codex.wordpress.org/Function_Reference/add_meta_box

You can then code it up to be a select box with each option in.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.