add_action('WCProductFilter_fields','WCProductFilter_field_my_custom_input', 30);
function WCProductFilter_field_my_custom_input(){
$WCProductFilter = isset($_GET['WCProductFilter']) ? sanitize_text_field($_GET['WCProductFilter']) :""; // check this to ensure for is submitted from WCProductFilter.
$_custom_input = isset($_GET['_custom_input']) ? sanitize_text_field($_GET['_custom_input']) :""; // Do not forget to sanitization
if(!$WCProductFilter):
$_custom_input = '';
endif;
/*
*
* you can check conditional here.
*
* if(is_shop()):
* execute code only shop page
* endif;
*
* */
if(is_shop()):
// this will only display under shop page and hide others page
?>
<div class="field-wrapper">
<div class="label-wrapper">
<label class=""><?php echo __('Custom Input','wc-product-filter'); ?></label>
</div>
<div class="input-wrapper">
<input type="search" placeholder="<?php echo __('Custom input','wc-product-filter'); ?>" name="_custom_input" value="<?php echo $_custom_input; ?>">
</div>
</div>
<?php
endif;
}
Use input field for query arguments
function wc_pf_query_args_custom_field($args, $form_data){
//default search query
$args['s'] = isset($form_data['_custom_input']) ? $form_data['_custom_input'] : '';
return $args;
}
add_action('wc_pf_query_args', 'wc_pf_query_args_custom_field');