I am using wp alchemy to add a custom metabox to my site with multiple image uploader option. This part is working fine, but I have no Idea how to go about outputting the image links to my template. I am hoping to output as a unordered list.
setup.php file
<?php
include_once WP_CONTENT_DIR . '/wpalchemy/MetaBox.php';
include_once WP_CONTENT_DIR . '/wpalchemy/MediaAccess.php';
// include css to help style our custom meta boxes
add_action( 'init', 'my_metabox_styles' );
function my_metabox_styles()
{
if ( is_admin() )
{
wp_enqueue_style( 'wpalchemy-metabox', get_stylesheet_directory_uri() . '/metaboxes/meta.css' );
}
}
$wpalchemy_media_access = new WPAlchemy_MediaAccess();
custom-spec.php
<?php
$custom_mb = new WPAlchemy_MetaBox(array
(
'id' => '_custom_meta',
'title' => 'Add images to home page slider',
'template' => get_stylesheet_directory() . '/metaboxes/custom-meta.php',
'include_template' => 'home.php'
));
?>
custom-meta.php
<?php global $wpalchemy_media_access; ?>
<div class="my_meta_control">
<p><a href="#" class="dodelete-docs button">Remove All</a></p>
<?php while($mb->have_fields_and_multi('docs')): ?>
<?php $mb->the_group_open(); ?>
<a href="#" class="dodelete button">Remove</a>
<?php $mb->the_field('imgurl'); ?>
<?php $wpalchemy_media_access->setGroupName('img-n'. $mb->get_the_index())->setInsertButtonLabel('Insert'); ?>
<p>
<?php echo $wpalchemy_media_access->getField(array('name' => $mb->get_the_name(), 'value' => $mb->get_the_value())); ?>
<?php echo $wpalchemy_media_access->getButton(); ?>
</p>
<?php $mb->the_field('title'); ?>
<label for="<?php $mb->the_name(); ?>">Title</label>
<p><input type="text" id="<?php $mb->the_name(); ?>" name="<?php $mb->the_name(); ?>" value="<?php $mb->the_value(); ?>"/></p>
<?php $mb->the_group_close(); ?>
<?php endwhile; ?>
<p style="margin-bottom:15px; padding-top:5px;"><a href="#" class="docopy-docs button">Add</a></p>
</div>
functions.php file
include_once 'metaboxes/setup.php';
include_once 'metaboxes/custom-spec.php';
Do you have any output code we can reference?
Put this in your Theme file:
if you have multiple you’ll have to go through a foreach loop:
Hope this helps, I don’t really know this Metabox class, however I’ve used many and it seems like it would work this way.
Good luck!
Here is the code I’m using:
Almost worked fine.