GetPostViews and SetPostViews in W3 Total Cache
-
Good day! I use the following code to count the number of hits on the site. Counters are working well, but because of the installation of W3 Total Cache views no longer be updated, and the views themselves are not considered. Podskzhaite, how can I fix it? Overwrite function in AJAX is not an option, so I just wanted to wean the W3 Total Cache from caching this particular query. I use Memcached
<?php echo getPostViews(get_the_ID()); ?>
<?php setPostViews(get_the_ID()); ?>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"; } echo _e('', 'dot-b'); return $count; } 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); } }
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘GetPostViews and SetPostViews in W3 Total Cache’ is closed to new replies.