#StackBounty: #custom-post-types #ajax #search #sort WordPress post sorting with AJAX

Bounty: 100

I am having a search result page for custom post type. I want to have a ajax sorting feature. Eg sort the post by taxonomy without reloading the page. A very basic example will help.
Thanks
enter image description here

The Search Form :

<form id="cptsearch" action="/" method="get">
    <input type="text" name="s" />
    <input type="hidden" name="post_type" value="lat" />
    <input id="searchsubmit" type="submit" alt="Search" value="Search" />
</form>

Template Chooser :

function template_chooser($template) {
    global $wp_query;
    $post_type = get_query_var('post_type');
    if( $wp_query->is_search && $post_type == 'lat' ) {
    return locate_template('page_lat.php');
    }
    return $template;
}
add_filter('template_include', 'template_chooser');

This is the output template page_lat.php :

Search Results (Currently only prints title and post type :

if($_GET['s'] && !empty($_GET['s'])){

  $text =$_GET['s'];
}
 ?>


 
-1, 's'=>$text ); $query= new WP_Query($args); while($query->have_posts()): $query->the_post(); ?>
<?php endwhile; wp_reset_query(); ?> </div>


Get this bounty!!!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.