Post Grid allows you to search and filter post by using 3rd party form or external form by GET method, there is a filter hook available you can use form submission data to query post on front-end.
Create a custom form shortcode:
i have created a custom form to display via widget on sidebar
add_shortcode('post_grid_search_form','post_grid_search_form');
function post_grid_search_form(){
$keyword = isset($_GET['keyword']) ? sanitize_text_field($_GET['keyword']) : '';
$year = isset($_GET['year']) ? sanitize_text_field($_GET['year']) : '';
$color = isset($_GET['color']) ? sanitize_text_field($_GET['color']) : '';
ob_start();
?>
<form method="get" action="">
<p>
<label>Search:</label><br>
<input name="keyword" type="search" value="<?php echo $keyword; ?>" placeholder="Keyword..">
</p>
<p>
<label>Year:</label><br>
<input name="year" type="text" value="<?php echo $year; ?>" placeholder="2019">
</p>
<p>
<label>Color:</label><br>
<input name="color" type="text" value="<?php echo $color; ?>" placeholder="Red">
</p>
<p>
<input type="submit" value="Submit">
</p>
</form>
<?php
return ob_get_clean();
}
Here is screenshot how its look like
Use form-data:
You can get form submission data via filter hook to query post via post grid, here is the code
function post_grid_filter_query_args_extra($query_args){
$keyword = isset($_GET['keyword']) ? sanitize_text_field($_GET['keyword']) : '';
//$year = isset($_GET['year']) ? sanitize_text_field($_GET['year']) : '';
//$color = isset($_GET['color']) ? sanitize_text_field($_GET['color']) : '';
$query_args['s'] = $keyword;
return $query_args;
}
add_filter('post_grid_filter_query_args','post_grid_filter_query_args_extra');
Here is the screenshot of search result after submit form
The same way you can use form data for meta field queries or taxonomies or terms query and etc.
