For this to work you need the date stored in the database to match the $todaysDate
and it probably doesn’t. If I am reading your somewhat confusing question correctly then you are storing dates like 20th Jan 2013
but you are matching it against a date that looks like 0120
(January 20). Even if you are are storing dates as a MySQL date, UNIX Timestamp, or as a somewhat more parsable string like 01-20-1975
it still isn’t going to match your comparison string.
Your solution is to understand what your data looks like and to search accordingly. I’d recommend storing as a MySQL date or a UNIX timestamp. Either can be programmatically manipulated fairly easily. Without more information– meaning a better question– I don’t know what else to say.
Based on additional information in a comment below:
Use meta_query
instead of meta_compare
.
$args = array(
'post_type' => 'persoane',
'posts_per_page' =>5,
'meta_query' => array(
array(
'key' => 'data_nasterii',
'value' => '__'.$todaysDate,
'compare' => 'LIKE'
)
)
);
$loop = new WP_Query( $args );
Used with LIKE
the underscore matches exactly one character so if your dates are consistently a two-digit year, two-digit-month, and two-digit day and if WP_Query passes the _
through unchanged (I have never tried. I don’t know.) that should match “any two characters followed by your generated date”. That is not going to be a very efficient query but given your data structure I think that is what you have to go with.