Reset Button
-
This shortcode returns the current number of hits. How do I reset this value?
function reset(){ $hits = intval( get_post_meta( get_the_ID(), Post_Hit_Counter()->_field, true ) ); printf( __( 'Views: %d', 'post-hit-counter' ), $hits ); } add_shortcode('reset-hits', 'reset');
In your code is written:
/** * Reset the post hit count via AJAX * @return void */ public function reset_hit_count() { if( isset( $_POST['post_id'] ) ) { $post_id = intval( $_POST['post_id'] ); if( $post_id ) { update_post_meta( $post_id, $this->_field, 0 ); echo 0; } } exit; }
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Reset Button’ is closed to new replies.