Title: Reset Button
Last modified: August 22, 2016

---

# Reset Button

 *  Resolved [WebTiago](https://wordpress.org/support/users/webtiago/)
 * (@webtiago)
 * [11 years, 3 months ago](https://wordpress.org/support/topic/reset-button-9/)
 * 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;
       	}
       ```
   
 * [https://wordpress.org/plugins/post-hit-counter/](https://wordpress.org/plugins/post-hit-counter/)

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Plugin Author [Hugh Lashbrooke](https://wordpress.org/support/users/hlashbrooke/)
 * (@hlashbrooke)
 * [11 years, 3 months ago](https://wordpress.org/support/topic/reset-button-9/#post-5839697)
 * Have a look at the plugin FAQ 🙂
 *  Thread Starter [WebTiago](https://wordpress.org/support/users/webtiago/)
 * (@webtiago)
 * [11 years, 3 months ago](https://wordpress.org/support/topic/reset-button-9/#post-5839701)
 * I have looked in the FAQ. I’m trying to customize creating a shortcode that resets
   the hits. Until now your plugin resets only in the post configuration panel.
 *  Plugin Author [Hugh Lashbrooke](https://wordpress.org/support/users/hlashbrooke/)
 * (@hlashbrooke)
 * [11 years, 3 months ago](https://wordpress.org/support/topic/reset-button-9/#post-5839795)
 * OK I see. In that case all you need to do is set the meta field value to `0` 
   like this:
 * `update_post_meta( $post_id, Post_Hit_Counter()->_field, 0 );`

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Reset Button’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/post-hit-counter_008c8c.svg)
 * [Post Hit Counter](https://wordpress.org/plugins/post-hit-counter/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/post-hit-counter/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/post-hit-counter/)
 * [Active Topics](https://wordpress.org/support/plugin/post-hit-counter/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/post-hit-counter/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/post-hit-counter/reviews/)

 * 3 replies
 * 2 participants
 * Last reply from: [Hugh Lashbrooke](https://wordpress.org/support/users/hlashbrooke/)
 * Last activity: [11 years, 3 months ago](https://wordpress.org/support/topic/reset-button-9/#post-5839795)
 * Status: resolved