Hi @coleds
If you put the date format like this it will only fetch the posts on that particular date. You cannot query on a format of a date, only the content of a meta value.
In your case I’d say that this particular field should always contain a date right? If so, just an non-empty check should be sufficient right?
Cheers, Jory
@keraweb I am query the date as the value. The meta_value is “2021-05-31” its saved as a string. I am doing a search in the postmeta for it to print out the post_title/name onto a calendar. As you can see here:
https://dev.svilleschools.com/events/
I am creating the calendar, then printing the $pods->total which equals zero. I am looping through each day to find info to echo. I have memorial day and a few other dates saved but nothing is being found.
Please advise.
Also if I try to use ‘orderby’ => ‘t.post_title ASC’ it continues it with:
ORDER BY t.post_title ASC, t.menu_order, t.post_title, t.post_date
Very strange.
I accomplished this using wpdb get_results with a simple query string…
If you can explain the below in Pods, it would be much appreciated. The docs are not very helpful.
$results = $wpdb->get_results("SELECT m.post_id,m.meta_value,p.post_title FROM ".$wpdb->postmeta." AS m LEFT JOIN ".$wpdb->posts." AS p ON m.post_id=p.ID WHERE m.meta_value='".$date."'");
Hi @coleds
Also if I try to use ‘orderby’ => ‘t.post_title ASC’ it continues it with:
ORDER BY t.post_title ASC, t.menu_order, t.post_title, t.post_date
These are default sorting additions.
If you can explain the below in Pods, it would be much appreciated. The docs are not very helpful.
Since you manually create your own query you don’t need anything Pod related. You just need to query the meta_value in relation to the meta_key.
When you use the .meta_value value postfix in combination with Pods then it will automatically add all required JOINS etc. to the query to make it work.
So, if you just want a single date (without time) then your initial post is almost correct. I believe you need to remove the first % wildcard in your LIKE query since date fields always start with the year, nothing else.
Cheers, Jory