I have a problem in my Events post-type. The events on my frontend are all showing the current date on my wordpress website

Question

i have installed lately the ACF plugin by Elliot Condon to manage my posted events on my website, I’ve put inside the WP_Query array the following: <?php
$today = date(‘Y-m-d’);
$homepageEvents = new WP_Query(array(
‘posts_per_page’ => 2,
‘post_type’ => ‘event’,
‘orderBy’ => ‘meta_value_num’,
‘meta_Key’ => ‘event_date’,
‘order’ => ‘ASC’,
‘meta_query’ => array(
array(
‘key’ => ‘event_date’,
‘compare’ => ‘>=’,
‘value’ => $today,
‘type’ => ‘numeric’
)
)

                           ));

and on my functions.php the following function:
function university_adjust_queries($query)
{
if (!is_admin() and is_post_type_archive(‘event’) and $query->is_main_query()) { //in order not to eleminate all the events in show all on backend
$today = date(‘Y-m-d’);
//$query->set(‘posts_per_page’, ‘1’); //these 3 queries written for the purpose of making the events by order in the archive page
$query->set(‘meta_key’, ‘event_date’);
$query->set(‘orderBy’, ‘meta_value_num’);
$query->set(‘order’, ‘ASC’);
$query->set(‘meta_query’, array(
array(
‘key’ => ‘event_date’,
‘compare’ => ‘>=’,
‘value’ => $today,
‘type’ => ‘numeric’
)
));
}
}

add_action(‘pre_get_posts’, ‘university_adjust_queries’);

but my events on the frontend are all showing the same as (current date) even when i post them manually at the calendar on the backend. any help please?

0
bassem kreidly 1 month 0 Answers 14 views 0

Leave an answer