Hi, today i will tech you how to show post view count without using plugin. it’s very easy, just copy below php code and past in your themes functions.php page.

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); } } // Remove issues with prefetching adding extra views remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0);

Now you can use below in single.php page where are location do you want to show post views count? must be input in your while loop.

setPostViews(get_the_ID()); 

Now you can input below code where are locations in do you want to show post views count. example: index page, post excerpt, etc….

echo getPostViews(get_the_ID()); 

Then you can see it’s working, if you need any help or if you have any problem then you can comment below this post, then i will reply for help you. thanks all, have a nice day.

পোস্টটি বাংলায় পরতে এখানে visit করুন

16 thoughts on "Show Post Views Count without plugin like trickbd"

  1. Paglu Contributor says:
    Kew Janabe pls Robi Free Net ki aj Off hoye gece??????
    amar choltecena
    1. Mosiurr Contributor says:
      mone hoy
  2. nathpcn Contributor says:
    robi free net ki bondho hoya gaca?
  3. Paglu Contributor says:
    amarto cholena
  4. Md Anamul Contributor says:
    bro closed..hoye geche
  5. Paglu Contributor says:
    Now ki Kono sim a ace jano kew???
  6. Rajkumar lll Contributor says:
    trickbd theme upload korte parini help me
    1. Prince Al-amin Author Post Creator says:
      ken ki problem hoy…
  7. WapmasterArif Contributor says:
    কেউ কি জনেন? Webtunnel কানেক্ট হচ্ছেনা কেন? জানলে প্লিস বলুন।অথবা অন্য একটা পোস্ট আমাদের মধ্যে শীঘ্র শেয়ার করুন। প্লিস।
    1. Arif Khan Contributor says:
      off hoye gese
  8. don902 Contributor says:
    robi. free net r nie….
  9. Shuhanur Rahman Contributor says:
    রফি ফ্রি নেট আর নেই। হারিয়ে গেছে। আর প্রিন্স ভাই [img]**[/img] এইটা যাতে সাপোর্ট করে সেই কোডটা দেন।
  10. WapmasterArif Contributor says:
    al amin bhay? apnar fb link den pls…
    kotha ace.

    fb.com/hd.jibon.503

  11. Prince Al-amin Author Post Creator says:
    Facebook.com/lovespot.ml
    1. Reja BD Author says:
      AMar Add Confrim korun

      fb.com/RejaRox

  12. hassanshajib Contributor says:
    Vhai amake akta valo theme den keo plzzz Ami j theme use korci kono na kono problem hocce plzz keo akta valo theme den

Leave a Reply