Вот код JS
$('.pages_list a').click(function(e){
e.preventDefault();
var postId = parseInt( $(this).attr('data-catid') );
postviewCountGet(postId);
});
function postviewCountGet(postId){
$( ".text" ).load( "<? echo bloginfo('template_url') . '/posts.php'?>" );
};
Вот posts.php
<?php
echo $postId;
?>
Как в WordPress переменную js var postId передать в переменную php $postId без перезагрузки страницы?
Чтобы передавать данные или делать запроса на сервер без перезагрузки страницы и форм вам понадобится AJAX.
Вот к примеру:
$.ajax({
type: "POST",
url: "some.php",
data: "variable=" + postId,
success: function(msg){
alert( "Прибыли данные: " + msg );
}
});
<?php
$postId = (isset($_REQUEST)) ? $_REQUEST : null;
А подробнее о AJAX тут http://api.jquery.com/jquery.ajax/
Продвижение своими сайтами как стратегия роста и независимости