Reset Thumbs Vote/count
-
If anyone wants to reset the votes/count of the thumbs, can be used the following code in the functions.php file.
function reset_thumbs_rating(){ if(is_front_page()){ $args = array ( 'post_type' => 'post', 'posts_per_page' => -1, ); $reset_thumbs_rating_query = new WP_Query($args); if ( $reset_thumbs_rating_query->have_posts() ) { while ( $reset_thumbs_rating_query->have_posts() ) { $reset_thumbs_rating_query->the_post(); $post_id = get_the_ID(); update_post_meta($post_id, '_thumbs_rating_up', null); update_post_meta($post_id, '_thumbs_rating_down', null); } } wp_reset_query(); wp_reset_postdata(); } } add_action('wp_footer', 'reset_thumbs_rating');
After adding the code, change the POST TYPE ID from the post_type parameter of the query for the post type you’re using it. I’ve used the default post type ID.
Then go to the homepage of the website and refresh the page. It should reset the votes.
If it does, then make sure to comment/remove the above code, otherwise, on each homepage refresh, the votes will be reset. ??
Thanks
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
- The topic ‘Reset Thumbs Vote/count’ is closed to new replies.