-
-
Save juanfra/ebf1a4399b2dfa835d4d to your computer and use it in GitHub Desktop.
Reset the viewcount.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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