Skip to content

Instantly share code, notes, and snippets.

@bigdawggi
Last active August 29, 2015 14:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bigdawggi/40d56ee4190e889fde7b to your computer and use it in GitHub Desktop.
Save bigdawggi/40d56ee4190e889fde7b to your computer and use it in GitHub Desktop.
admin-ajax call
<?php
function get_user_snippet(){
$id = intval( $_GET['user_id'] );
global $post;
$post = get_post( $id );
setup_postdata( $post );
get_template_part( 'partials/user-snippet');
exit;
}
add_action('wp_ajax_get_user_snippet', 'get_user_snippet');
add_action('wp_ajax_nopriv_get_user_snippet', 'get_user_snippet');
/* Build the URL with the following */
echo add_query_arg(
array(
'action' => 'get_user_snippet',
'user_id' => intval( 234 ),
),
admin_url( 'admin-ajax.php' )
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment