代码工作!
我有两种定制的post类型:Events和Artists。我正在使用WPAlchemy MetaBox PHP类,试图在Events post编辑器中使用一系列动态创建的复选框(即,每个Artists帖子将有一个复选框)创建一个metabox,这将允许我选择在Event中出现哪个Artists。
任何帮助或洞察力都非常感谢!谢谢!
这段代码可以很好地显示复选框(来自checkbox_meta.php):
<div class="my_meta_control">
<label>Group checkbox test #2</label><br/>
<?php
global $post;
$artists = get_posts('post_type=artists');
foreach($artists as $artist) :
setup_postdata($artist);
$slug = $artist->post_name;
?>
<?php $mb->the_field('cb_ex2', WPALCHEMY_FIELD_HINT_CHECKBOX_MULTI); ?>
<input type="checkbox" name="<?php $mb->the_name(); ?>" value="<?php echo $slug; ?>"<?php $mb->the_checkbox_state($slug); ?>/><?php echo $artist->post_title; ?><br/>
<?php endforeach; ?>
<input type="submit" class="button-primary" name="save" value="Save">
</div>这段代码来自functions.php:
include_once 'assets/functions/MetaBox.php';
if (is_admin()) wp_enqueue_style('custom_meta_css', 'wp-content/themes/bam/assets/css/meta.css');
define('THEMEASSETS', STYLESHEETPATH . '/assets');
$custom_metabox = new WPAlchemy_MetaBox(array
(
'id' => '_custom_meta',
'title' => 'My Custom Meta',
'types' => array('sp_events'),
'template' => THEMEASSETS . '/functions/checkbox_meta.php'
));发布于 2011-05-03 19:14:26
我开发了一个帮助类,它可以帮助您使用创建wordpress元框。
发布于 2011-05-03 17:49:11
我认为这条线是问题所在
$data = stripslashes_deep($_POST['artist']);试着把它改成
$data = stripslashes_deep($_POST);https://stackoverflow.com/questions/5850650
复制相似问题