Query Multiple Taxonomies
ajax support (4 posts)

  1. krakra
    Posted 2 years ago #

    Would it be easy to have ajax support so that the page won't reload after every wiget change? Anybody tried that?


  2. mypixel
    Posted 2 years ago #

    You can do a "hijack" of the widget form submit and then use AJAX to load in the results to your existing page.
    Something like this worked for me (using jQuery):

    $('.taxonomy-drilldown-checkboxes').submit(function() {
    		// catch the form's submit event
    		target_el = $('div.target');
    		target_el.empty().html('<br/><h2>Please wait, loading...</h2>');
    	    $.ajax({ // create an AJAX call...
    	        data: $(this).serialize(), // get the form data
    	        type: $(this).attr('method'), // GET or POST
    	        url:  $(this).attr('action'), // the file to call
    	        success: function(response) { // on success..
    	        	// update the DIV - uses the "archive" template.
    	    return false; // cancel original event to prevent form submitting
  3. webtomeasure
    Posted 1 year ago #

    Hi mypixel,

    I have been trying to follow your suggestion above. I'd like to implement this using ajax. I have one query though. Can you show your server side PHP code that responds to the AJAX call? I'd like to see how you implement the GET query in the data on the server side to set the query parameters for selecting only the relevant posts that meet the selection criteria. I can't quite figure how to do that.


  4. jpisanu
    Posted 1 year ago #

    Hi @mypixel, sorry to revive this old post but I used your snippet successfully and it works. I'm facing some issues with it though and want to see if you can help me.

    The code works perfectly until you paginate stuff. Let's suppose that you have a custom post type and you list all posts with a regurlar WP_Query, then if you paginate it and you're in page 2 this won't show anything when you try to apply filters.

    I also added infinite scroll (which is the way I want to do) to this applied to the .target div. It makes that the URL doesn't change so I'm able to go to the archive even if I'm on page 3.

    The issue under this setup is that when you applied filters and then you get paginated results, when you scroll down to make infinite start working it starts querying posts outside the chosen taxonomies filter/s.

    If you want to take a look at my code please let me know and I will be happy to show you.


Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Query Multiple Taxonomies
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic


No tags yet.