Buradasın
WordPress yazıların okunma sayısı nasıl öğrenilir?
Yazeka
Arama sonuçlarına göre oluşturuldu
WordPress yazıların okunma sayısını öğrenmek için aşağıdaki yöntemler kullanılabilir:
- Eklenti Kullanımı:
- Manuel Kod Ekleme:
- Temanın functions.php dosyasına aşağıdaki kod eklenerek okunma sayısı görüntülenebilir 5.
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 görüntülenme.'; } return $count.' defa okundu.'; } 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); } }
Bu kod,
single.phpdosyasına eklenerek sayım yapılabilir 5. Okunma sayısının görüntüleneceği yere ise şu kod eklenir 5:
<?php echo getPostViews(get_the_ID()); ?>
Bu yöntem, her eklenti kullanımında ortaya çıkabilecek SEO sorunlarına yol açmadan sağlıklı bir sayım sağlar 5.
5 kaynaktan alınan bilgiyle göre: