You could possibly look at doing this the same way that WP Job Manager does:
https://github.com/Automattic/WP-Job-Manager/blob/master/assets/js/ajax-filters.js
This is done by triggering a handler to make the query defining what “page” the query should run against. I would recommend using that as an example to build off of, as it works with both filters applied and none being applied.
ALSO ALWAYS ALWAYS ALWAYS SANITIZE USER DATA
Anywhere you’re using $_POST
$_GET
$_REQUEST
etc you should always sanitize the data before using it anywhere. Best to get in the habit of it or bad things could eventually happen.
https://developer.wordpress.org/themes/theme-security/data-sanitization-escaping/
Related Posts:
- Click loads template via ajax
- How to speed up admin-ajax.php in wordpress
- Ajax request not sending to server and returning – wp-admin/admin-ajax.php 400
- dynamic dependent select dropdown
- How to disable controls in theme customizer?
- Function won’t run onclick using Ajax
- Why i can’t get custom fields value or post ID via Ajax?
- Post not populating for custom post type based on category selection
- How to get post category list as select in front-end?
- Execute Jquery when a specific page in my plugin is loading
- Database entry removed on browser refresh, Ajax PHP jQuery
- Update $wpdb query with AJAX
- How to call a function from functions.php with ajax?
- Custom Post type Ajax search results
- Find the method which AJAX GET calls
- ajax form function error
- AJAX: WordPress filters inside $html do not work as intended
- I got this error POST https://localhost/meraboilerwp/[object%20Object] 404 (Not Found)
- How can I fetch loop of post titles via AJAX?
- Retrieve POST data from AJAX call
- username_exists() function can’t be access without logging in
- Do I require the use of nonce?
- Build a content and excerpt grid loop with paging and options for # of posts
- WordPress Ajax always returns a 404 error
- Is it possible to get a theme customizer setting from wp.customize using jquery?
- problem with ajax and the path to the php page
- Can i check if user is doing any ajax request?
- Display notification only once
- How to retrieve the content (with a specific ID) via ajax by clicking a link tag
- Access/update database with jQuery
- How to display something in a div when the user clicks on a text in another div – no page refresh [closed]
- Passing jQuery value using Ajax to a page template
- ajax_object is not defined when ajax calls the function
- Returning a value from a PHP page
- Why is this Ajax not working?
- Stumped – Ajax Response Returns 0
- Colorbox ajax loading of outside HTML content works perfect on localhost but not on server
- Sending jsPDF documents to the server
- Use wp_get_recent_posts with search term
- Use ajax from function.php
- Remove query string specific key value
- Ajax return code 400
- wp_insert_post() is returning the correct post ID, no failure, but the post content does not get updated
- doing an ajax request always outputs 0
- How to test nonce with AJAX – Plugin development
- Can’t search posts using WP_QUERY inside AJAX Function
- Woocommerce add to cart quantity buttons with AJAX
- WooCommerce – Reset quantity input field when variation changes
- class click counter save number
- get post based on category chosen in drop down – The ajax method
- Checking for new message using AJAX and PHP. Server overload?
- jQuery not defined
- AJAX request status 200 but no actual “response”
- get current custom post ID by WP_Query method
- Conditional Header in wordpress
- Create another “Display Site Title and Tagline” checkbox, “Header Text Color” setting and control
- wordpress count link clicks by ip address
- ajax, right way to do it and make it works?
- Ajax load more posts with multiple tax query
- How to store data from multiple forms using ajax and php
- WordPress Sending data to Ajax with select option
- PHP 8, AJAX mail form to function.php doesn’t work
- WordPress ajax doesn’t display object method on jQuery .change() function
- Ajax loaded form replaces form action with Ajax url
- prevent default not stopping page refresh. Passing form information to and from php with ajax in a wordpress site
- Pass Category Name, Description and Photo into variables to pass to jQuery
- How to prevent WP_Query function from returning all posts when empty?
- Display a specific category of products in shop page and disable code for specific actions
- Ajax date_query not working past the first iteration
- Why ajax doesn’t work on certain wordpress hooks and reload the page instead?
- Why ajax doesn’t work on certain wordpress hooks?
- Is it possible to intercept all ajax requests and get the parameters and the returns?
- AJAX pagination, update current page
- Save Search System
- adjust section according to country?
- populate form fields in a loop with ajax
- WordPress, AJAX and pre_get_posts using conditional tags
- Change “add to cart” button color based on Woocommerce product category [closed]
- How can I get the values of my WordPress $wpdb query in Jquery?
- Ajax request returns ‘Array’. How to output the actual results?
- Get users that likes the post
- Ajax load more button for comments wordpress
- How to add a do_action on refreshing of WP customizer?
- Setting value of session with Ajax not working
- how to make custom ajax handler?
- [jQuery]Adding shortcode
- Display parent and child taxonomies in separate drop down select fields
- Show success or error messages in Ajax response to WordPress custom registration form
- How to add a Custom Mailchimp AJAX Newsletter Subscribe Form
- Remove echo from shortcode
- Plugins not working on AJAX requests
- Fancybox type popup window that’s not an iframe
- Can I use a jQuery Ajax request in Code Snippets Plugin for WordPress?
- How do I Import / Upload Files with jQuery AJAX?
- WordPress admin-ajax.php 400 bad request
- Security for data obtained from the database
- WordPress Ajax Call inserting data but success response false
- Ajax contact form return 0
- AJAX – Returning Two JSON Objects with One PHP Function
- Pull GetOption() variable into jQuery dynamically created html