Hi all
I'm having fun and games (well, not really fun) trying to get a SELECT statement to work on a wordpress website and wondered if anyone out there could help.
Basically I am trying to retrieve 10 posts that have an expiry date of today. Selecting 10 posts is fine, the problem start when I try to filter it based on date.
SELECT * FROM wp_posts WHERE post_type = "listing" LIMIT 10
However the expiry date is held in a different table;
Table: wp_postmeta
Field: listing_expiry_date
Date: is stored in a column called meta_value (in mm-dd-yyyy format)
I suspect the link between wp_posts and wp_postmeta takes place using post_id. Although I know what it is that needs to happen, I'm at a loss as to how to code it correctly;
SELECT * FROM wp_posts WHERE post_type = "listing" WHERE meta_value IN listing_expiry_date in wp_postmeta = TODAY LIMIT 10
Can anyone please advise how to go about this?
Many thanks