Решил с помощью Ajax
<script type="text/javascript">
jQuery.ajax({
type:'get',
url:'wp-count.php',
data:{'id':'<? echo get_the_ID(); ?>'},
response:'text',
success:function (data) {
console.log(data);
}
});
</script>
<?
/** Sets up the WordPress Environment. */
require( dirname(__FILE__) . '/wp-load.php' );
$postID = $_GET['id'];
echo $postID;
if($postID>0) {
$count_key = 'post_views_count';
$count = get_post_meta($postID, $count_key, true);
if ($count == '') {
$count = 0;
delete_post_meta($postID, $count_key);
add_post_meta($postID, $count_key, '0');
echo 'add_0';
} else {
$count++;
update_post_meta($postID, $count_key, $count);
echo 'add';
}
}
?>