i'm using this function for click count of downloads in wordpress.
Function.php
function setdownViews($postID) {
$dcount_key = 'post_download_count';
$dcount = get_post_meta($postID, $dcount_key, true);
if($dcount==''){
$dcount = 0;
delete_post_meta($postID, $dcount_key);
add_post_meta($postID, $dcount_key, '0');
}else{
$dcount++;
update_post_meta($postID, $dcount_key, $dcount);
}
}
and this jequery code to call this function after click on download link.
$(document).on('click', "#click-count", function () {
<?php setdownViews(get_the_ID());?>
});
but not working and meta value of post_download_count not updating.
i know i should use ajax and jquery to call this function but don't know how.
best regards.