Skip to content

Instantly share code, notes, and snippets.

@juanfra
Last active September 21, 2015 14:16
Show Gist options
  • Save juanfra/ebf1a4399b2dfa835d4d to your computer and use it in GitHub Desktop.
Save juanfra/ebf1a4399b2dfa835d4d to your computer and use it in GitHub Desktop.
Reset the viewcount.
<?php
//* Do NOT include the opening php tag
// trigger the function
nice_reset_viewcount();
// define the function.
function nice_reset_viewcount() {
$query = new WP_Query( 'post_type=article' );
if ( $query->have_posts() ) :
while ( $query->have_posts() ) : $query->the_post();
update_post_meta( get_the_ID(), '_pageview_count', 0 );
endwhile;
endif;
wp_reset_postdata();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment