php - Comparing WP dates -
i´m trying show posts meta field "fecha_inicio" contains younger date format "dd/mm/yyyy" 1 variable has date same format "dd/mm/yyyy". code next one:
$args = array( 'posts_per_page' => 30, 'post_type' => 'programa', 'paged' => get_query_var( 'paged' ), 'meta_query' => array( array( 'key' => 'fecha_inicio', 'value' => $fecha, 'type' => 'date', 'compare'=> '<' ), ), );
this doesn´t return me anything. have posts example date 10/10/2016 , 01/01/2016, , i´m trying query date in middle 05/05/2016, , it´s not returning me
i have printed variable , shows correct date, , other dates correct on database, dunno missing here.
also field has same name, in table post_meta
trying show sql query
select sql_calc_found_rows wp_posts.id wp_posts inner join wp_postmeta on ( wp_posts.id = wp_postmeta.post_id ) 1 = 1 and( ( wp_postmeta.meta_key = 'fecha_inicio' , cast(wp_postmeta.meta_value date) > '01/05/2095' ) ) , wp_posts.post_type = 'programa' and( wp_posts.post_status = 'publish' or wp_posts.post_status = 'private' ) group wp_posts.id order wp_posts.post_date desc limit 0, 30
Comments
Post a Comment