Why is my custom loop not filtering correctly nor paginating?

Hopefully someone can help me with this as I’ve been struggling for a few days.

I’ve built a form on a page that lets users filter Events by custom taxonomies Type, Period and Duration. These are working individually i.e. the filter shows all posts with either Type=x or Period=y but not combined. Can anyone see why?

Here’s my code in Pastie

I’m also trying to figure out how to paginate my results for my custom loop, but can’t figure out why it’s not working?

Any help massively appreciated.

Thanks

osu

EDIT

Ok, for some reason, I can’t use the array method to pass my variables to query_posts() and I’m assuming this is because with the plugin Query Multiple Taxonomies which I need installed for this to work, it only works with the method ‘post_type=event&fttype=daily’ etc.

Here’s my new code which is working:

http://www.pastie.org/1586564

HOWEVER, even though the pagination is working when you first visit the page, after you submit the form, the pagination stops working. So, nearly nearly there, but I need some help with the last part if anyone can be so kind?

Thanks

osu

Solutions Collecting From Web of "Why is my custom loop not filtering correctly nor paginating?"

To fix your “query filters”
change

// Set defaults in nothing entered:
if(!isset($_POST['showfilter'])) {
    $ft_args = 'post_type=ftevent&';
    // $ft_args .= 'posts_per_page=1&'; SHOW ALL
    $ft_args .= 'paged=' . $paged . '&';
    $ft_args .= $osu_datecompare . '&';
    $ft_args .= 'orderby=meta_value&order=ASC';
} else {
    // Filter query with multiple taxonomies and paginate results
    $ft_args = 'post_type=ftevent&';
    $ft_args .= 'posts_per_page=2&';
    $ft_args .= 'paged=' . $paged . '&';
    $ft_args .= 'fttype=' . $ft_t . '&';
    $ft_args .= 'ftperiod=' . $ft_p . '&';
    $ft_args .= 'ftduration=' . $ft_d . '&';
    $ft_args .= $osu_datecompare . '&';
    $ft_args .= 'orderby=meta_value&order=ASC';
}

to

// Filter query with multiple taxonomies and paginate results
    $ft_args = array(
    'post_type' => 'ftevent',
    'posts_per_page' => 2,
    'paged=' => $paged ,
    'meta_key' => 'StartEventDate',
    'meta_compare' => '>=',
    'meta_value' => $todaysDate,
    'orderby' => 'meta_value',
    'order' => 'ASC');
    if (isset($ft_t) && ($ft_t != '')){$ft_args['fttype'] = $ft_t;}
    if (isset($ft_p) && ($ft_p != '')){$ft_args['ftperiod'] = $ft_p;}
    if (isset($ft_d) && ($ft_d != '')){$ft_args['ftduration'] = $ft_d;}

and to make it work before version 3.1 you will need to install Query Multiple Taxonomies.

Hope this helps.