Skip to content

Instantly share code, notes, and snippets.

@educartoons
Created November 7, 2018 03:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save educartoons/e8cc76dab0aab69933dde4f7ededb66d to your computer and use it in GitHub Desktop.
Save educartoons/e8cc76dab0aab69933dde4f7ededb66d to your computer and use it in GitHub Desktop.
function my_enqueue_assets() {
wp_enqueue_script( 'ajax-function', get_stylesheet_directory_uri() . '/js/ajax-function.js', array(), '1.0.0', true );
wp_localize_script( 'ajax-function', 'ajaxfunction', array(
'ajaxurl' => admin_url( 'admin-ajax.php' )
));
}
my_enqueue_assets();
add_action('wp_ajax_get_chaplains', 'get_chaplains_callback');
add_action('wp_ajax_nopriv_get_chaplains', 'get_chaplains_callback');
function get_chaplains_callback(){
echo json_encode($result);
wp_die();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment