Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › Uncheck all custom post types › Reply To: Uncheck all custom post types
Hi!
To uncheck all of those options, I would use this script line:
[code]$(‘input[name*=customset]’).removeAttr(‘checked’);[/code]
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:
[html]<a href=’#’ class=’asp_uncheck_cpt’>My link</a>[/html]
…and the script:
[html]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’);
});
});[/html]
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!