• Resolved Krissieg

    (@krissieg)


    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:

    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 to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support Mahfuzul Alam

    (@mahfuz87)

    Hello @krissieg

    It is possible by custom development and template overriding. Please learn more from here – Template Override (directorist.com)

    Step 1: Please overrider the template ( wp-content/plugins/directorist/templates/search-form/buttons.php ) with the following 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 –

    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

    (@krissieg)

    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

    (@krissieg)

    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/

    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.