How do i search post by jquery datepicker?

I’m working on the WordPress website I have my own search filter page, where I added the jquery datepicker, now I want to search post by datepicker?

Html Code

script>
$(function() {

jQuery( “#datepicker-13” ).datepicker({
dateFormat : “yy-mm-dd”
});
$(“#datepicker-13”).datepicker().datepicker(“setDate”, new Date());
});
</script>

<input type = “text” name=”datefrom” class=”form-control alertform” id = “datepicker-13”>

WordPress Query

$datefrom = $_POST[‘datefrom’];

if(!empty($datefrom) && $datefrom !==”)
{
$args = array(
‘post_type’ => ‘post’,
‘posts_per_page’ =>8,
‘paged’ => $paged,
‘post_date’ => $datefrom,
‘post_status’ => ‘publish’
);
}
$my_query = new WP_Query($args);

Read more here:: How do i search post by jquery datepicker?

Leave a Reply

Your email address will not be published. Required fields are marked *