Depends what you are getting back from the ‘date_event’ post-meta field.
That’s probably the culprit here — if it’s an actual date with a month and day, it’s not going to match what you are getting from date(‘Y’), which is just going to be ‘2018’.
You can check the value in ‘date_event’ on any of the agenda posts with:
print_r( get_post_meta( $post_id, ‘date_event’, true ) );
If the value in ‘date_event’ is a Unix timestamp, that actually makes it easy because then you can just query for all dates starting with Jan 1 of the current year, something like:
$first_of_year = strtotime( "1 January " . date( 'Y' ) );
$args = array( 'post_type' => 'agenda',
'posts_per_page' => -1,
'meta_key' => 'date_event',
'orderby' => 'meta_value_num',
'order' => 'ASC',
'meta_query' => array(
array(
'key' => 'date_event',
'value' => $first_of_year,
'compare' => '>=',
).
),
'tax_query' => array(
array(
'taxonomy' => 'event_type',
'field' => 'term_id',
'terms' => $type_name,
)
)
);
If date_event is giving you a value like 20180320, you could do something similar, but with …
$first_of_year = date( 'Y' ) . '0101';
If you are getting something like ‘2018-03-29’ that’s when you might need to use the ‘type’ => ‘DATE’ — but if you have one of the first two situations, you don’t need it.
One other thing: ‘sort_order’ isn’t a valid param, though it’s just going to be ignored). You just want ‘order’, which you had lower down anyway.
Ans when you are comparing numeric values it’s best practice to change ‘orderby’ => ‘meta_value’ to ‘orderby’ => ‘meta_value_num’.