Advertisement
Guest User

Untitled

a guest
Jun 18th, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement