SHARE
TWEET

Untitled

a guest Jun 18th, 2019 56 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function setPostViews($postID) {
  2.     $count_key = 'post_views_count';
  3.     $count = get_post_meta($postID, $count_key, true);
  4.     if($count == '') {
  5.         $count = 0;
  6.         delete_post_meta($postID, $count_key);
  7.         add_post_meta($postID, $count_key, '0');
  8.     }
  9.     else {
  10.         $count++;
  11.         update_post_meta($postID, $count_key, $count);
  12.     }
  13.  
  14.     add_action('end_session_action','end_session');
  15. }
  16.  
  17. function getPostViews($postID){
  18.     $count_key = 'post_views_count';
  19.     $count = get_post_meta($postID, $count_key, true);
  20.     if($count==''){
  21.         delete_post_meta($postID, $count_key);
  22.         add_post_meta($postID, $count_key, '0');
  23.         return "0 View";
  24.     }
  25.     return $count;
  26. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top