How to add your custom fields to the search widget

With the new remastered search widget and shortcodes you can now add additional search parameters.

Add custom search parameters to EPL - Search Widget

Add your options to the search widget

The first filter will add your options to the search widget.

// Add Custom Options to Search Widget
function my_epl_custom_search_fields_callback( $array ) {

	$array[] = array(
		'key'			=>	'custom_search_checkbox_1',
		'label'			=>	__('Custom Checkbox 1','epl'),
		'default'		=>	'off',
		'type'			=>	'checkbox',
	);
	$array[] = array(
		'key'			=>	'custom_search_checkbox_2',
		'label'			=>	__('Custom Checkbox 2','epl'),
		'default'		=>	'off',
		'type'			=>	'checkbox',
	);
	$array[] = array(
		'key'			=>	'custom_search_checkbox_3',
		'label'			=>	__('Custom Checkbox 3','epl'),
		'default'		=>	'off',
		'type'			=>	'checkbox',
	);
	return $array;
}
add_filter( 'epl_search_widget_fields' , 'my_epl_custom_search_fields_callback' );

Add your options to the displayed search widget

Now you add the search options to the displayed form and control how the search query works.

Add custom search parameters to displayed EPL - Search Widget

// Add Custom Search Items to Front End
function my_epl_custom_search_widget_fields_frontend_callback( $array ) {

	$array[] = array(
		'key'		=>	'custom_search_checkbox_1',
		'meta_key'	=>	'custom_search_key_1',
		'label'		=>	__('Custom Checkbox 1', 'epl'),
		'type'		=>	'select',
		'option_filter'	=>	'custom_search_filter_1',
		'options'	=>	array(
					'1' => '1',
					'2' => '2',
					'3' => '3',
					'4' => '4',
		),
		'exclude'	=>	array('land','commercial','commercial_land','business'),
		'query'		=>	array(
						'query'		=>	'meta',
						'key'		=>	'custom_property_meta_key_1',
						'type'		=>	'numeric',
						'compare'	=>	'<='
					),
		'class'		=>	'epl-search-row-full',
	);

	$array[] = array(
		'key'		=>	'custom_search_checkbox_2',
		'meta_key'	=>	'custom_search_key_2',
		'label'		=>	__('Custom Checkbox 2', 'epl'),
		'type'		=>	'select',
		'option_filter'	=>	'custom_search_filter_2',
		'options'	=>	array(
					'100' => '100',
					'200' => '200',
					'300' => '300',
					'400' => '400',
		),
		'exclude'	=>	array('land','commercial','commercial_land','business'),
		'query'		=>	array(
						'query'		=>	'meta',
						'key'		=>	'custom_property_meta_key_2',
						'type'		=>	'numeric',
						'compare'	=>	'<='
					),
		'class'		=>	'epl-search-row-half',
		'wrap_start'	=>	'epl-search-row custom_search_class_1',
	);

	$array[] = array(
		'key'		=>	'custom_search_checkbox_3',
		'meta_key'	=>	'custom_property_meta_key_3',
		'label'		=>	__('Custom Checkbox 3', 'epl'),
		'type'		=>	'select',
		'option_filter'	=>	'custom_search_filter_2',
		'options'	=>	array(
					'100000' => epl_currency_formatted_amount('100,000'),
					'200000' => epl_currency_formatted_amount('200,000'),
					'300000' => epl_currency_formatted_amount('300,000'),
					'400000' => epl_currency_formatted_amount('400,000'),
		),
		'exclude'	=>	array('land','commercial','commercial_land','business'),
		'query'		=>	array(
						'query'		=>	'meta',
						'key'		=>	'custom_property_meta_key_3',
						'type'		=>	'numeric',
						'compare'	=>	'<='
					),
		'class'		=>	'epl-search-row-half',
		'wrap_end'	=>	true
	);
	return $array;
}
add_filter( 'epl_search_widget_fields_frontend' , 'my_epl_custom_search_widget_fields_frontend_callback' );