Skip to content

Instantly share code, notes, and snippets.

@juanfra
Last active May 24, 2016 17:47
Show Gist options
  • Save juanfra/a15e07fc0edb187fc0565f066dafed25 to your computer and use it in GitHub Desktop.
Save juanfra/a15e07fc0edb187fc0565f066dafed25 to your computer and use it in GitHub Desktop.
Reset likes in Flatbase
<?php
//* Do NOT include the opening php tag
// trigger the function
nice_reset_likes();
// define the function.
function nice_reset_likes() {
$query = new WP_Query( 'post_type=article' );
if ( $query->have_posts() ) :
while ( $query->have_posts() ) : $query->the_post();
update_post_meta( get_the_ID(), '_like_count', 0 );
update_post_meta( get_the_ID(), '_like_ip', '' );
endwhile;
endif;
wp_reset_postdata();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment