我正在使用wp alchemy向我的站点添加一个带有多个图像上传器选项的自定义metabox。这部分工作正常,但我不知道如何将图像链接输出到我的模板。我希望输出为无序列表。
设置。php文件
<?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\'
));
?>
自定义元。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>
功能。php文件
include_once \'metaboxes/setup.php\';
include_once \'metaboxes/custom-spec.php\';