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 1 year ago.

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

    gsxrgeek
    Participant

    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.
    <code>

    global $sitemap_mb;
    $sitemap_mb->the_meta();

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

    </code>

    This is the spec.php file:
    <code>

    $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']);
    }

    </code>

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

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

    <div class=”my_meta_control”>

    <p>
    <?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.
    </p>

    </div>

    </code>

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

    #2545

    Dimas
    Key Master

    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”

    #2547

    gsxrgeek
    Participant

    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.