2

コードが機能します!

と の 2 つのカスタム投稿タイプがEventsありArtistsます。私はWPAlchemy MetaBox PHP クラスを使用しておりArtistsEvents投稿エディターで一連の動的に作成されたチェックボックス (つまり、投稿ごとにチェックボックスがあります) を持つメタボックスを作成しようとしています。ArtistsEvent

どんな助けや洞察も大歓迎です!ありがとう!

このコードはチェックボックスを表示するのにうまく機能します (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'
));
4

2 に答える 2

1

wordpress メタ ボックスの作成に役立つヘルパー クラスを開発しました。

于 2011-05-03T19:14:26.437 に答える
0

この行が問題だと思います

$data = stripslashes_deep($_POST['artist']);

に変更してみてください

$data = stripslashes_deep($_POST);
于 2011-05-03T17:49:11.587 に答える