<?php
/*
Theme Designed By: Meysam Hosseinkhani
Email: Meysam98@Gmail.com
Author Website: Hosseinkhani.ir
*/
   // Exit if accessed directly
   if ( ! defined( 'ABSPATH' ) ) exit;
   //Views
   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 "بدون بازدید";
   }
   return $count.' بازدید';
   }
    
   // function to 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);
   }
   }
   
   ?>