Use Ajax To filter posts?

I’d go with @Vinicius’ answer with the following changes:

  1. Change type: 'GET' to type: 'POST'

  2. Change ajax: 1 to action: 'filter_posts'

  3. Replace add_action('init', 'check_ajax'); with:

    add_action(‘wp_ajax_filter_posts’, ‘check_ajax’);
    add_action(‘wp_ajax_nopriv_filter_posts’, ‘check_ajax’);

  4. Remove:

    if (!isset($_POST[‘ajax’]))
    return false;