EA Share Count – Delete Current Counts

Useful if you forgot to use production URL so have a bunch of zero counts.

<?php
/**
* Delete share count data
*
*/
function be_delete_share_count_data() {
$loop = new WP_Query( array(
'posts_per_page' => 100,
'meta_key' => 'ea_share_count',
'fields' => 'ids',
) );
if( $loop->have_posts() ):
foreach( $loop->posts as $post_id ) {
delete_post_meta( $post_id, 'ea_share_count' );
delete_post_meta( $post_id, 'ea_share_count_datetime' );
delete_post_meta( $post_id, 'ea_share_count_total' );
}
endif;
}
add_action( 'wp_footer', 'be_delete_share_count_data' );
view raw functions.php hosted with ❤ by GitHub

Bill Erickson

Bill Erickson is a freelance WordPress developer and a contributing developer to the Genesis framework. For the past 14 years he has worked with attorneys, publishers, corporations, and non-profits, building custom websites tailored to their needs and goals.

Ready to upgrade your website?

I build custom WordPress websites that look great and are easy to manage.

Let's Talk