Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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');
?>
share|improve this question

2 Answers 2

up vote 1 down vote accepted

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.

share|improve this answer

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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