Skip to content

Instantly share code, notes, and snippets.

@wurwal
Created February 3, 2023 18:33
Show Gist options
  • Save wurwal/08bd642c8844ea15b7681909f3b87eb3 to your computer and use it in GitHub Desktop.
Save wurwal/08bd642c8844ea15b7681909f3b87eb3 to your computer and use it in GitHub Desktop.
detect no posts on repeaters with or without facetwp
//when facets change dynamically - delete if using on a regular page load based repeater
jQuery(document).on('facetwp-loaded', function() {
// if repeater id contains something that it would if it returned posts
if (jQuery('#_dynamic_list-9-148 h2').length > 0) {
// hide no posts error
jQuery('.no-results').hide();
// otherwise the no results message shows
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment