danielbachhuber/Edit-Flow — pull request #165 by cojennin (2013-02-23 18:59:47+00:00)
Title: Filters on budget

This is the same sort of code from the calendar applied to the budget to fix issue #105. This pull requests gives the user the ability to add any number of select elements to the top navigation in the budget.

The only significant difference between the code from the calendar and this code is how the user needs to deal with the 'posts_query_args_filter'. In the calendar, the filter would be applied like so:

function add_genre_query($args){
if(!empty($_GET['genre'])){
$args['tax_query'] = array (
array (
'taxonomy' => 'genre',
'field' => 'slug',
'terms' => esc_attr($_GET['genre']),
),
);
}
return $args;
}

Now, it should look something like this:

function sb_add_genre_query($args){
if(!empty($_GET['genre'])){
$temp_args = $args['tax_query'];
$temp_args[] = array (
'taxonomy' => 'genre',
'field' => 'slug',
'terms' => esc_attr($_GET['genre']),
);
$args['tax_query'] = $temp_args;
}
return $args;
}

The budget relies on using the category taxonomy to organize stories, so someone who wants to utilize the posts_query_filter would need to just add another taxonomy array so they don't overwrite the taxonomy array for category.