so I'm developing a WordPress website, I'm using "Advanced Custom Fields" plugin. I added two fields groups one by the name event_date with a type date and the second one by the name related_service with a type relationship, the related_service it shows in the event type post to relate a service to an event. so in the page single service I want to show the upcoming events that are related to the service. I used WP_Query to show posts from post_type events. i did a piece of code but something is wrong and and don't know what I did wrong. this code is showing all the events that are coming in the future but not related to the service, so the first array in the meta_query seems to work perfectly buy the second one I don't know what's wrong with it . the code :
<?php
$UpcomingRealeatedEvents = new WP_Query(array(
'post_type' => 'event',
'posts_per_page' => 2,
'meta_key' => 'event_date',
'orderby' => 'meta_value_num',
'order' => 'ASC',
'meta_query' => array(
array(
'relation' => 'AND',
'key' => 'event_date',
'compare' => '>=',
'value' => date('Ymd'),
'type' => 'numeric',
),
array(
'key' => 'related_service',
'compare' => 'LIKE',
'value ' => '"'.get_the_ID().'"'
)
)
));
while ($UpcomingRealeatedEvents->have_posts()) {
$UpcomingRealeatedEvents->the_post();
?>
<div >
<a href="<?php the_permalink(); ?>" target="_blank"><i aria-hidden="true"></i><?php the_title(); ?></a>
</div>
<?php } ?>
I tried every thing I can.
CodePudding user response:
I found the problem guys and it was so stupid hahahahha this think is just there is a space near to 'value' in the meta_query