function setPostViews($postID) {
$count = get_post_meta($postID, 'post_count', true);
$count++;
update_post_meta($postID, 'post_count', $count);
echo $count.;
}
function setPostViews($postID) {
$count = get_post_meta($postID, 'post_count', true);
$count++;
update_post_meta($postID, 'post_count', $count);
echo $count.;
}
if( current_user_can('author') || current_user_can('editor') || current_user_can('administrator') ){
function setPostViews($postID) {
$count = get_post_meta($postID, 'post_count', true);
$count++;
update_post_meta($postID, 'post_count', $count);
echo $count.;
}
setPostViews($postID)
либо в новой таблице, либо в метаполе
function Agent($postID) {
$DDD = get_post_meta($postID, 'TOT', true);
if ($DDD == ''){
$DDD = 1;
update_post_meta($postID, 'TOT', $DDD);
echo 'Yes TTTYYYTTT';
}
}
Agent(get_the_ID()) ;
function Agent($postID) {
$uid = get_current_user_id();
$DDD = get_user_meta( $uid, 'TOT', true );
if ( !$DDD || !isset($DDD[$postID]) ){
$DDD[$postID] = 1;
update_user_meta($uid, 'TOT', $DDD);
echo 'Yes TTTYYYTTT';
}
}
Agent(get_the_ID()) ;
function create_table(){
global $wpdb ;
$mebd =" CREATE TABLE post_counts
(idpost CHAR(25) NOT NULL,
iduser CHAR(25) NOT NULL,)";
$wpdb ->query($mebd);
}
function agent($postid) {
global $wpdb;
$uid = get_current_user_id();
$wpdb->get_results( "SELECT iduser FROM post_counts WHERE idpost='" . $postid . "' AND iduser='" . $uid . "'");
if ($wpdb->num_rows < 1) {
... тря-ля-ля что нужно сделать ...
$wpdb->query("INSERT INTO post_counts (idpost, iduser) VALUES('" . $uid . "','" . $postid . "')");
} else {
... тра-ля-ля уже тут были ...
}
}