0

I've written a class that outputs various JSON data from my postmeta. I'm able to call this within my theme on a template page. However, when it's inside my save_post it will not fire. I've put other code in generate_markers() to confirm that it triggers, it just doesn't seem to like what I'm doing with the class loopmap_query.

Here is the function in question:

function generate_markers(){
    $debug_this = false;

    $default_markers = new loopmap_query('all', 'default', 'wp-content/plugins/loopden/json/map_default.json', $debug_this);
    $todays_markers = new loopmap_query('all', 'today', 'wp-content/plugins/loopden/json/map_today.json', $debug_this);
    $tommorrows_markers = new loopmap_query('all', 'tomorrow', 'wp-content/plugins/loopden/json/map_tomorrow.json', $debug_this);
    $all_markers = new loopmap_query('all', 'all', 'wp-content/plugins/loopden/json/map_all.json', $debug_this);

    $default_markers->generate_map_data();
    $todays_markers->generate_map_data();
    $tommorrows_markers->generate_map_data();
    $all_markers->generate_map_data();
}

It would go into:

add_action( 'save_post', 'ap_meta_box_save' );

function ap_meta_box_save( $post_id )
{
    //
    generate_markers();
}

Any ideas why this would work inside my single page file and not in save_post?

  • 1
    What does generate_map_data() do? – Jacob Peattie Sep 12 '17 at 3:28
  • It runs a wordpress query, gathers all the post meta I want and then outputs it into a json file. – Chris Stage Sep 12 '17 at 13:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.