If you copy the code from line 1423 till 1444 and place it in a new function in the functions.php that you then call in a custom template.
Do make sure to include the ‘wpsl-custom-dropdown’ class in the $args and use a different ID. The ‘wpsl-custom-dropdown’ class makes sure the selected values are automatically included in the submitted AJAX data.
You will also have to modify the SQL query and place holders to do something with the submitted data.
Hi Tjimen,
Thanks for the quick reply and suggestions. I have created this function in my themes functions.php
//add a second category dropdown in the search filters
function nm_add_second_category_filter(){
$category = '<div id="wpsl-loyalty">' . "\r\n";
$category .= '<label for="wpsl-loyalty-list">Loyalty Program</label>' . "\r\n";
$args = apply_filters( 'wpsl_dropdown_category_args', array(
'show_option_none' => 'Any',
'option_none_value' => '0',
'orderby' => 'NAME',
'order' => 'ASC',
'echo' => 0,
'selected' => $this->set_selected_category( $filter_type ),
'hierarchical' => 1,
'name' => 'wpsl-loyalty',
'id' => 'wpsl-loyalty-list',
'class' => 'wpsl-dropdown wpsl-custom-dropdown',
'taxonomy' => 'wpsl_store_category',
'hide_if_empty' => true
)
);
$category .= wp_dropdown_categories( $args );
$category .= '</div>' . "\r\n";
}
but am coming a little unstuck trying to include it in my custom template. Currently I am doing this but is stooping the page from loading.
if ( $this->use_category_filter() ) {
$output .= $this->create_category_filter();
//include the second category filter
$output .= nm_add_second_category_filter();
}
Also, can you advise why I would need to modify the sql query as it is still just a (additional) category that is being filtered?
Many thanks,
Rob
Currently I am doing this but is stooping the page from loading.
Can you check the server error log, it will likely explain the problem.
Also, can you advise why I would need to modify the sql query as it is still just a (additional) category that is being filtered?
The default category filter will be passed in the AJAX data in the filter param, additional ( custom ) dropdowns will not be assigned to the same key / value pair. The key of the custom dropdowns is based on the name value, and this will by default not be processed in the SQL query, unless you tell it to.