This is my code
function ajax_layoutcontrol(){
if( !check_ajax_referer( 'special-string','security')){
return wp_send_json_error( 'Invalid nounce');
}
if (! current_user_can('manage_options')){
return wp_send_json_error('You are not allowed to do this');
}
$orderwppl= $_POST['order']; // This is an array['phone', 'email']
remove_shortcode( 'sideblock' );
add_shortcode( 'sideblock', 'new_order' );
function new_order(){
foreach ($orderwppl as $item) {
get_template_part( 'content', $item );
}
}
wp_send_json_success( 'Post Saved');
die();
}
add_action( 'wp_ajax_save_listing_order', 'ajax_layoutcontrol');
i am tring to change the shortcode
function old_order(){
get_template_part( 'content', 'email' );
get_template_part( 'content', 'phone' );
}
add_shortcode('sideblock', 'old_order');
But this is not working as ajax throws 500 error Please help