Working with multiple values and metaboxes
-
30-10-2019 - |
문제
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.
- Song 1
- Song 2
- 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');
?>
올바른 솔루션이 없습니다
제휴하지 않습니다 wordpress.stackexchange