501788 adding second and third metabox (Wordpress)
N/A
Käynnissä
Julkaistu lähes 13 vuotta sitten
N/A
Maksettu toimituksen yhteydessä
I have this code:
<code>
$prefix = 'dbt_';
$meta_box = array(
'id' => 'help-section-video',
'title' => 'Help Section',
'page' => 'video',
'context' => 'side',
'priority' => 'high',
'fields' => array(
array(
'name' => '',
'class' => 'calendar',
'id' => $prefix . 'text',
'type' => 'calendar',
'std' => ''
),
array(
'name' => '',
'class' => 'contributor_tutorial_video',
'id' => $prefix . 'text',
'type' => 'contributor',
'std' => ''
),
array(
'name' => '',
'class' => 'editor_tutorial_video',
'id' => $prefix . 'text',
'type' => 'editor',
'std' => ''
),
array(
'name' => '',
'class' => 'producer_tutorial_video',
'id' => $prefix . 'text',
'type' => 'producer',
'std' => ''
),
)
);
add_action('admin_menu', 'mytheme_add_box');
// Add meta box
function mytheme_add_bo1() {
global $meta_box;
add_meta_box($meta_box['id'], $meta_box['title'], 'mytheme_show_box', $meta_box['page'], $meta_box['context'], $meta_box['priority']);
}
// Callback function to show fields in meta box
function mytheme_show_box() {
global $meta_box, $post;
// Use nonce for verification
echo '<input type="hidden" name="mytheme_meta_box_nonce" value="', wp_create_nonce(basename(__FILE__)), '" />';
echo '<table class="form-table">';
foreach ($meta_box['fields'] as $field) {
// get current post meta data
$meta = get_post_meta($post->ID, $field['id'], true);
echo '<tr class="', $field['class'], '">',
'<td>';
switch ($field['type']) {
case 'calendar': ?>
<a href="" onClick="MyWindow=[login to view URL]('/calendar','MyWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=950,heigh t=380'); return false;"><input type="button" style="width:244px" value="Show Calendar" /></a>
<?php echo '', '';
break;
//link #!
case 'contributor':
echo '<a title="How to create an Article with Video" class="thickbox" id="add_image" href="[login to view URL]"><input type="button" style="width:244px" value="Contributor Video Tutorial" /></a>';
break;
//link #2
case 'editor':
echo '<a title="How to create an Article with Video" class="thickbox" id="add_image" href="[login to view URL]"><input style="width:244px" type="button" value="Contributor Video Tutorial" /></a>';
break;
//link #3
case 'producer':
echo '<a title="How to create an Article with Video" class="thickbox" id="add_image" href="[login to view URL]"><input style="width:244px" type="button" value="Contributor Video Tutorial" /></a>';
break;
}
echo '<td>',
'</tr>';
}
echo '</table>';
}
</code>
i'd like to add this same metabox into post and audio (custom post type)
I'd also like to be able to change the links #1, #2, #3 for each post type.
Let me know if you need more info or this is enough and you know what to do. it should be easy task for somebody who knows wordpress and php.
Thanks
Jan