Wordpress - Compare date - October is bigger than November (Y-m-d)

D

dcer

Guest
I'm developing an event booking, everything works correctly with this query, that is, it puts the posts according to the order of magnitude correctly

<?php
$v_args = array(
'post_type' => get_option('customer_postquery'),
'posts_per_page' => -1,
'orderby' => 'meta_value',
'order' => 'ASC',
'meta_query' => array(
array (
'key' => 'metakey_AMC_data',
),
),
'tax_query' => array(
array(
'taxonomy' => 'categoria',
'field' => 'slug',
'terms' => $queried_object,
)
)

);
$vehicleSearchQuery = new WP_Query( $v_args );


if( $vehicleSearchQuery->have_posts() ) :?>

<?php while( $vehicleSearchQuery->have_posts() ) : $vehicleSearchQuery->the_post();
?>
<?php
$var = get_post_meta(get_the_ID(),'metakey_AMC_data',true);
$data_dell_evento = date("Y-m-d", strtotime( $var ));
/*PRENDERE LA DATA CORRENTE IN FORMATO Y-m-d DIRETTAMENTE DA MYSQL*/
$data_di_oggi = date( 'Y-m-d', current_time( 'timestamp', 0 ) );
if ($data_dell_evento > $data_di_oggi ): ?>

<div style="padding-top: 25px;" class="col-md-4"><!-- Card -->
<?php include('content/home_page/card.php'); ?>
</div>

<?php endif; ?>

<?php
endwhile;
else :
?>

<?php
endif;
wp_reset_postdata();
?>


where: get_option('customer_postquery'), recovers all the custom post types created

where: metakey_AMC_data, is the meta key where the event date is enclosed in the respective meta_value

where: $queried_object, it retrieves the taxonomy based on the taxonomy page we are in

The problem is that it perfectly filters all the dates of October, example


  • 2019/10/05


  • 2019/10/10


  • 2019/10/15

but when I insert a date for the following month, for example (2019/11/01), November gives me a little bit smaller than everyone, changing the arrangement in this way


  • 2019/11/01


  • 2019/10/05


  • 2019/10/10


  • 2019/10/15

how to fix this?

more information:

when instead I am on the event page, so I entered the page where I have all the information, this query is the one that regulates all future events only of that custom post type without distinction of taxonomies, in this case not putting get_option and not putting no taxonomy, the dates are displayed perfectly

$v_args = array(
'post_type' => array('eventi-suite'),
'posts_per_page' => -1,
'post_status' => 'publish',
'order' => 'ASC',
'meta_query' => array(
array (
'key' => 'metakey_AMC_data',

),
),


);

Continue reading...
 
Top