admin管理员组文章数量:1301514
General View I am creating a plugin which imports a csv file and using a shortcode i created a form that can search values from the uploaded csv file in sqlData base. Form have Three Input fields
- Search by Date(Using a date picker)
- Search by Name(text type)
- Search by Text (text Type)
Problem: I am Getting the right data by using both of the text Field but The Date picker isnt getting any match.
HTML Form
<h1>Find Your Brick</h1>
<form action="" method="post">
<!-- Purchase Date -->
<label for="">
<h5 style="display:inline;margin-left:2rem">Search By Purchase Date</h5>
<input type="date" name="purchase_date">
</label>
<br>
<br>
<label for="">
<h5 style="display:inline;margin-left:2rem ; margin-right:1rem">Donor Name</h5>
<input type="text" id="textInput" placeholder="Search Here..." name="donor_name" >
</label>
<br>
<br>
<label for="">
<h5 style="display:inline;margin-left:2rem ; margin-right:1rem">Brick Text</h5>
<input type="text" id="textInput1" placeholder="Search Here..." name="brick_text" >
</label>
<input type="submit" name="submit" value="SUBMIT" style="margin-left:5rem"> </form>
Meta query This is my meta query
if (isset($_POST['submit'])) {
$brick_text = $_POST['brick_text']; //Brick Taste
$donor_name = $_POST['donor_name']; //Donor Name
$purchase_date = $_POST['purchase_date']; //Date of Purchase
$newDate = date("d/m/y", strtotime($purchase_date));
$args = array(
'post_type' => 'brick',
'posts_per_page' => -1,
'meta_query' => array(
array(
'key' => 'donor_name',
'value' => $donor_name,
'compare' => 'LIKE',
),
array(
'key' => 'purchase_date',
'value' => $newDate,
'compare' => 'LIKE',
),
array(
'key' => 'brick_text',
'value' => $brick_text,
'compare' => 'LIKE',
),
),
'orderby' => 'meta_value',
'order' => 'ASC',
);
}
What I have Tried
I have tried using the the php date function to convert the format of date of the date picker i'm using in the form Your Help will be really appreciated
本文标签: pluginsUsing metaquery to get date type values from postmeta table WordPress
版权声明:本文标题:plugins - Using meta_query to get date type values from post_meta table WordPress 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741678909a2392047.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论