В фале functions.php
add_action('wp_ajax_nopriv_ajax_order', 'ajax_form' );
add_action('wp_ajax_ajax_order', 'ajax_form' );
function ajax_form(){
global $postId;
$postId = $_REQUEST['name'];
if ( defined( 'DOING_AJAX' ) && DOING_AJAX ){
echo $postId;
wp_die();
}
}
В файле publications.php
$('.pages_list a').click(function(e){
e.preventDefault();
postId = $(this).attr('data-catid');
$.ajax({
url: "/wp-admin/admin-ajax.php",
method: 'post',
data: {
action: 'ajax_order',
name: postId
},
success: function (response) {
var content = "<? echo $postId; ?>";
$("#thumbs").html(content);
}
});
});
В publications.php переменная $postId не выводится, но она есть в response. Как вывести переменную php $postId в publications.php?
Продвижение своими сайтами как стратегия роста и независимости