Öneri ve reklamlar için iletişim adresimiz: info@bilgihanesi.com
WordPress’te Sayfa Kaç Kez Bakıldı Okundu (Views) Gösterme (Eklentisiz)
WordPress kullanıcıları için oldukça gerekli bir özellik olan sayfa ziyaret gösterim, orjinal adıyla The Views yani konunun kaç kez okunduğunu gösteren işlemi nasıl eklentisiz olarak yapabileceğinizi anlatacağım bugün sizlere..
Öncelikle aşağıda görmüş olduğunuz kodu temanız içerisinde bulunan functions.php içerisine kopyalayıp yapıştırıyorsunuz..
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.' Views'; } 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); } }
Ardından aşağıda ki kodu single.php içerisinde nerde görünmesini istiyorsanız oraya yapıştırıyorsunuz;
<?php setPostViews(get_the_ID()); ?> <?php echo getPostViews(get_the_ID()); ?>
İşlemimiz bu kadar.. Artık sitenizde eklentiye ihtiyaç duymadan konu ya da sayfalarınız kaç kez görüntülenmiş öğrenebilirsiniz..
paylaşım ıcın tesekkurler