Uncheck all custom post types

Home Forums Product Support Forums Ajax Search Pro for WordPress Support Uncheck all custom post types

This topic contains 1 reply, has 2 voices, and was last updated by Ernest Marcinko Ernest Marcinko 6 years ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #15691
    Luciano Petrosini
    Luciano Petrosini
    Participant

    Hello, I am trying to make a personalization of the “Frontend Search Settings options” area in the public part but I can not do it.

    Basically I’m trying to put a link that when clicked deactivates all checkboxes at one time (in custom post types), but since these checkboxes are customized and I can not find the script with which this is done or I can not do that remain unchecked as you would with a normal checkbox with jquery.

    Is there any way to put a link that deactivates all filters or that this option is disabled by default?

    Thank you very much ( Sorry for my english 🙂 )

    #15693
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Hi!

    To uncheck all of those options, I would use this script line:

    $('input[name*=customset]').removeAttr('checked');

    More specificly
    Let’s make a script, which detects a link with the class ‘asp_uncheck_cpt’ and attaches a click event to it, which executes the upper code.

    Place the link anywhere you want it, just make sure to add the class ‘asp_uncheck_cpt’ to it:

    <a href='#' class='asp_uncheck_cpt'>My link</a>

    …and the script:

    jQuery(function($){
      $('a.asp_uncheck_cpt').on('click', function(e) {
        // Disable default click event
        e.preventDefault(); 
        // Stop the event propagation
        e.stopPropagation();
        
        // Uncheck all checkboxes in the custom post type section
        $('input[name*=customset]').removeAttr('checked');
      });
    });

    This script needs to be placed into the site footer, for that I recommend this code. Add this custom code to the functions.php in your theme/child theme directory (copy from line 3 only!). Before editing, please make sure to have a full site back-up just in case!

    I hope this helps!

    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.