Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Other Using jquery to load wordpress loop based on select field.

  • This topic is empty.
Viewing 1 post (of 1 total)
  • Author
    Posts
  • #31794
    dkanderson
    Member

    Hi guys I am, new here and I need help. I am trying to filter some content in wordpress based on a dropdown menu. Right now my query loads a list of post of a custom post type. like so:


    if (have_posts()) {
    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    query_posts( 'posts_per_page=24&paged='.$paged.'&post_type=discount_partners' );
    }
    ?>

    ID, 'discount', true); ?>
    ID, 'tel', true); ?>

















  • That works great and the results are paged with wp-pagenavi. What I have be struggling with is a way to further filter this from a dropdown list based on a particular category within the custom post type: “discount_partners”;

    my approach thus far was to use jquery.post() function and use a php file with just the modified loop but it somehow doesn’t recognize the wordpress functions at all when jquery calls it like so:


    $("#filter_partners").click(function(){
    var selectedCategory = $("#select_category").val();
    var selectedParish = $("#select_parish").val();
    $("#qresults").hide('slow');
    $.post("/select_results.php", {queryParish: ""+selectedParish+"", queryCategory: ""+selectedCategory+""}, function(data) { // Do an AJAX call
    $('#show_results').fadeIn(); // Show the results
    $('#show_results').html(data); // Fill the results box with new filtered query
    });
    return false;
    });

    I hope I have explained enough so my dilemma is understood. I think my problem is I am taking the wrong approach, but I am fairly new to jquery and just trying to piece ideas together i will take any help any suggestions at this point I will continue to tinker and hope. Stata Buon.

Viewing 1 post (of 1 total)
  • The forum ‘Other’ is closed to new topics and replies.