How can I filter / query wordpress posts using ajax, live?

I have a WordPress website, that has a number of posts, and a number of filters (with only the UI set up) in a theme that is a custom build.

Want I want to to do is change the query posts tags live using AJAX, so that the user can get the posts they want using the filters:

Read More
  • Popularity (custom taxonomy)
  • Time posted
  • Tags
  • Colour (custom),
  • Keyword (using a search bar)
  • Category

I have found a php script that does a similar thing, but not live, and does not give the ability to update live; this script is here that does the query.

<?php if( !empty($_GET['order']) ) $order=$_GET['order'];
else $order='DESC'; // default

if( !empty($_GET['orderby']) ) $orderby=$_GET['orderby'];
else $orderby = 'Date'; // default
if( !empty($_GET['cat']) ) $orderby=$_GET['cat'];
else $category = ''; // default


query_posts('orderby='.$orderby.'&order='.$order.'&meta_key='.'_post_like_count'.'&cat='.$category)
            ?>

The script that does the changing (that changes the queries) is here, effectively an anchor that adds a url onto the the search term.

<a href="?order=DESC&orderby=meta_value_num">Popular</a>

I have only done the querying for a few values, before I get the whole filtering system working, and I acknowledge that it may have to be completely re done, as I know that ajax cannot change the url live for the user, and has to use requests.

Does anyone know how I could approach this task in any way, and can someone give me some guidance on how to achieve it?

I am open to plugins, yet I would prefer integrating it locally into my custom theme build.

Related posts