Title: Reset Filter Button doesn&#8217;t work properly
Last modified: February 13, 2024

---

# Reset Filter Button doesn’t work properly

 *  Resolved [Krissieg](https://wordpress.org/support/users/krissieg/)
 * (@krissieg)
 * [2 years, 3 months ago](https://wordpress.org/support/topic/reset-filter-button-doesnt-work-properly/)
 * Hi there, I was hoping someone can help me with applying a link to refresh the
   page when selecting the ‘reset filters’ button. At the moment the reset button
   only clears the filters selected but doesn’t refresh the page so that it clears
   the url and resets to the total amount of listings found. We find this confusing
   that the reset filter button doesn’t reset the listings number total as well.
   So, the support team have provided me with the php that controls the reset filter
   button and said to change the class name to create an anchor link? Thing is I’m
   not a coder and this is a bit out of my comfort zone, so I was hoping some kind
   soul that can code will see this post and help me? Here is the php code:
 *     ```wp-block-code
       if ( ! defined( 'ABSPATH' ) ) exit;
       ?>
   
       <div class="directorist-advanced-filter__action directorist-flex directorist-justify-content-end">
   
       	<?php if ( $searchform->has_apply_filters_button ): ?>
       		<button type="submit" class="directorist-btn directorist-btn-sm directorist-btn-dark"><?php echo esc_html( $searchform->apply_filters_text ); ?></button>
       	<?php endif; ?>
   
       </div>
       ```
   
 * All I want to do is add the link to that page as the reset filters button link,
   so that the page refreshes and then the listing total also goes back to its correct
   and original total. The support team say it’s out of their scope of help, so 
   if anyone knows how to do this, I’d be most grateful. The website is a charity
   site and I’ve been working on it for free, so I can’t expect them to pay out 
   for customisation development either. So I’m a bit stuck. 🙁
 * Thanks in advance, if anyone can help! Or point me in the right direction! 🙂
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Freset-filter-button-doesnt-work-properly%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

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

 *  Plugin Support [Mahfuzul Alam](https://wordpress.org/support/users/mahfuz87/)
 * (@mahfuz87)
 * [2 years, 3 months ago](https://wordpress.org/support/topic/reset-filter-button-doesnt-work-properly/#post-17426616)
 * Hello [@krissieg](https://wordpress.org/support/users/krissieg/)
 * It is possible by custom development and template overriding. Please learn more
   from here – [Template Override (directorist.com)](https://directorist.com/documentation/directorist/developers-guide/template-override/)
 * Step 1: Please overrider the template ( wp-content/plugins/directorist/templates/
   search-form/buttons.php ) with the following code –
 *     ```wp-block-code
       <?php
       /**
        * @author  wpWax
        * @since   6.6
        * @version 7.0.5.6
        */
   
       if ( ! defined( 'ABSPATH' ) ) exit;
       ?>
   
       <div class="directorist-advanced-filter__action directorist-flex directorist-justify-content-end">
   
       	<?php if ( $searchform->has_reset_filters_button ): ?>
       		<a href="#" style="visibility: hidden" class="directorist-btn directorist-btn-sm directorist-btn-outline-dark directorist-btn-reset-js"><?php echo esc_html( $searchform->reset_filters_text ); ?></a>
       		<a href="#" class="directorist-btn directorist-btn-sm directorist-btn-outline-dark directorist-reset-filter-button" id="directorist-reset-filter-button">Reset Filters</a>
       	<?php endif; ?>
   
       	<?php if ( $searchform->has_apply_filters_button ): ?>
       		<button type="submit" class="directorist-btn directorist-btn-sm directorist-btn-dark"><?php echo esc_html( $searchform->apply_filters_text ); ?></button>
       	<?php endif; ?>
   
       </div>
       ```
   
 * Step 2: Use the following code in the functions.php file of the current active
   child theme folder or you can use a code snippet plugin –
 *     ```wp-block-code
       add_action( 'wp_footer', function(){
       ?>
       	<script type="text/javascript">
       		jQuery('document').ready(function($){
       			$('#directorist-reset-filter-button').click(function(e){
       				e.preventDefault();
       				$('.directorist-btn-reset-js').trigger('click');
       				window.location.href = window.location.protocol + '//' + window.location.hostname + window.location.pathname
       			});
       		});
       	</script>
       <?php
       } );
       ```
   
 * This should server you purpose.
 * Please let me know if you need further assistance.
 * Kind Regards
 *  Thread Starter [Krissieg](https://wordpress.org/support/users/krissieg/)
 * (@krissieg)
 * [2 years, 3 months ago](https://wordpress.org/support/topic/reset-filter-button-doesnt-work-properly/#post-17435681)
 * Hi Mahfuzul, thanks sooo much!Just a couple more queries:
    1.  I’ve checked out the override template documentation. I’m intrigued as to how
       this does not get copied over when updating the plugin. Is it not possible to
       use your code within a child theme for it to work? Sorry, I’m not a coder so
       this is interesting for me to understand why I can’t just put both of the codes
       within a code snippet plugin or child theme?
    2. The code you’ve supplied what will this do when you select ‘reset filters’ button?
 * Thanks again for your help, it’s much appreciated!
 *  Thread Starter [Krissieg](https://wordpress.org/support/users/krissieg/)
 * (@krissieg)
 * [2 years, 2 months ago](https://wordpress.org/support/topic/reset-filter-button-doesnt-work-properly/#post-17559619)
 * Hey Mahfuzul, I finally had a chance to test this out on a staging version of
   our live site and unfortunately it doesn’t seem to work. I followed the instructions
   but the reset filter doesn’t set the total number back to its original amount
   when I select reset filters. Here is the test site if you don’t mind taking a
   look? [https://test.bwcsa.co.za/humane-guide/](https://test.bwcsa.co.za/humane-guide/)
 * Many thanks for your help!

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

The topic ‘Reset Filter Button doesn’t work properly’ is closed to new replies.

 * ![](https://ps.w.org/directorist/assets/icon-256x256.gif?rev=3185058)
 * [Directorist: AI-Powered Business Directory, Listings & Classified Ads](https://wordpress.org/plugins/directorist/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/directorist/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/directorist/)
 * [Active Topics](https://wordpress.org/support/plugin/directorist/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/directorist/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/directorist/reviews/)

 * 3 replies
 * 2 participants
 * Last reply from: [Krissieg](https://wordpress.org/support/users/krissieg/)
 * Last activity: [2 years, 2 months ago](https://wordpress.org/support/topic/reset-filter-button-doesnt-work-properly/#post-17559619)
 * Status: resolved