Pass authentication data through REST API requests
By default, the WordPress REST API doesn’t pass along authentication data.
If your FacetWP template depends on the current logged-in user, you’ll run into issues when an AJAX refresh is triggered.
Fortunately, there’s an easy workaround:
/* Please note that caching may interfere with the NONCE, causing ajax requests to fail. Please DISABLE CACHING for facet pages, or set the cache expiration to < 12 hours! */ add_action( 'wp_footer', function() { ?> <script> (function($) { $(function() { FWP.hooks.addFilter('facetwp/ajax_settings', function(settings) { settings.headers = { 'X-WP-Nonce': FWP_JSON.nonce }; return settings; }); }); })(jQuery); </script> <?php }, 100 );