Saving Data…Array Empty

Home Forums WPAlchemy Saving Data…Array Empty

This topic contains 2 replies, has 2 voices, and was last updated by  gsxrgeek 2 years, 7 months ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
  • #2544


    I have a checkbox on each post/page that when checked I want to collect the post id and save it to perform a function with all the post id’s saved. My code is below and don’t think the information is saving. Any help would be appreciated.

    In the functions file to output all the post id’s saved at once. This is in a function.

    global $sitemap_mb;

    $args = array(
    ‘meta_key’ => ‘_sitemap_meta’,
    ‘orderby’ => ‘meta_value’,
    ‘order’ => ‘ASC’,
    ‘posts_per_page’ => -1,
    $myarray = query_posts( $args );
    var_dump( $myarray );
    echo $myarray;


    This is the spec.php file:

    $sitemap_mb = new WPAlchemy_MetaBox(array
    ‘id’ => ‘_sitemap_meta’,
    ‘title’ => ‘Sitemap Exclusion’,
    ‘template’ => get_stylesheet_directory() . ‘/metaboxes/sitemap-meta.php’,
    ‘save_action’     => ‘pull_featured_data’

    function pull_featured_data($meta, $post_id) {
    update_post_meta($post_id, ‘_sitemap_meta’, $meta[‘exclude’]);


    This is the meta.php file that shows on each post.

    global $post;
    $hide = get_post_meta($post->ID, ‘_sitemap_meta’, true);

    <div class=”my_meta_control”>

    <?php $mb->the_field(‘show-sitemap’); ?>
    <input type=”checkbox” name=”<?php $mb->the_name(); ?>” value=”exclude” <?php $mb->the_checkbox_state(‘exclude’); ?> />
    Exclude this page from the sitemap.



    The rendered html is this: array(0) { } Array. Nothing outputs. Not sure what I am doing wrong. Thanks!!



    good idea using the save_action filter .. you might try using a different name for the new post meta as to not interfere with how wpalchemy saves and recalls its own data for its meta box .. something like “_in_sitemap”



    Thanks for your response! But I am not sure what you mean by “new post meta”.

    Are you talking about this? Changing exclude to something else?
    update_post_meta($post_id, ‘_sitemap_meta’, $meta[‘exclude’]);

    Thanks for your help.

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.