Double count
-
Within a shortcode I like to count my page views. Every time when i count a view with a custom field, it doubles the count. It counts for 2 instead of 1.
Does someone has any idea what could be the reason and how to solve it?function update_gelezen($postid) { $date = date('Y-m-d'); update_field('leesdatum', $date, $postid); $now = get_field('leesteller',$postid); $now = (int) $now; $new = $now + 1; update_field('leesteller', $new, $postid); } add_shortcode('showportfolio', 'myportfolio'); function myportfolio() { $result = ‘’; $query = new WP_Query(array( 'post_type' => 'lscontentblock', 'posts_per_page' => -1, 'orderby'=>'date', 'order'=>'ASC' )); while ($query->have_posts()) { $query->the_post(); $post_id = get_the_ID(); $result .= “[blahblahblah]”; update_gelezen($post_id); } wp_reset_query(); return do_shortcode($result) ; }
The page I need help with: [log in to see the link]
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘Double count’ is closed to new replies.