Created
December 13, 2018 18:13
-
-
Save usainicola/d41d27c6d3b9e927f588a548e067819e to your computer and use it in GitHub Desktop.
wp ajax get template part
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 ajax_get_template_part() { | |
check_ajax_referer('ajax_get_template_part','nonce'); | |
$part = esc_attr($_POST['template_part']); | |
if (!$part) {return;} | |
get_template_part($part); | |
die(); | |
} | |
add_action( 'wp_ajax_nopriv_ajax_get_template_part', 'ajax_get_template_part' ); | |
add_action( 'wp_ajax_ajax_get_template_part', 'ajax_get_template_part' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment