Gösterim takip kodu
single.php
<!-- gösterim sayısı -->
<?php setPostViews(get_the_ID()); ?>
------
Gösterim sayısını göstermek istediğiniz yere
<?php echo getPostViews(get_the_ID()); ?>
---
Function.php
/* gösterim sayısı */
function getPostViews($postID){
$count_key = 'post_views_count';
$count = get_post_meta($postID, $count_key, true);
if($count==''){
delete_post_meta($postID, $count_key);
add_post_meta($postID, $count_key, '0');
return "0 View";
}
return $count.' Gösterim';
}
function setPostViews($postID) {
$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');
}else{
$count++;
update_post_meta($postID, $count_key, $count);
}
}
// Remove issues with prefetching adding extra views
remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0);
/*******************/
kaynak: https://www.yenibirsey.net/wordpress-eklentisiz-yazi-ve-sayfalarin-okunma-sayilarini-gosterme/