Last active
August 29, 2015 14:21
-
-
Save bigdawggi/40d56ee4190e889fde7b to your computer and use it in GitHub Desktop.
admin-ajax call
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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