Я создаю пользовательский макет для последних событий и хотел бы получить время и местоположение события, а также цену через WP_Query, но, похоже, не удается получить все поля, доступные для сообщения типа события
Оттуда я запросил сообщение типа события (event_manager). Мне удалось получить поля ACF, но не поля, прикрепленные к самому событию.
$args = array(
'numberposts' => 4,
'offset' => 0,
'orderby' => 'post_date',
'order' => 'DESC',
'include' => '',
'exclude' => '',
'meta_key' => '',
'meta_value' =>'',
'post_type' => 'event',
'post_status' => 'publish',
'suppress_filters' => false,
);
$the_query = new WP_Query( $args ); ?>
<?php print_r($the_query) ?>
<h2 style='text-align:center'>Latest Conversations</h4>
<div class='home-con-cards conversations'> <?php
while ($the_query -> have_posts()) : $the_query -> the_post(); ?>
<?php //the_excerpt(); ?>
<div class='conversation-header' style="flex-grow: 6">
<?php //print_r($the_query->posts) ?>
<h4> <a href="<?php the_permalink(); ?>"> <?php the_title(); ?> </a> </h4>
<p>[ Date & Time ] - [ Location ]</p>
<p>[ Price ]</p>
<?php
$hosts = get_field( 'conversation_hosts', $the_query->ID );
foreach($hosts as $host) { ?>
<div class='host'>
<?php the_author_meta('user_url') ?>
<span><?php echo $host['host'][0]['user_avatar'];?>
<h4><?php echo $host['host'][0]['display_name'] ?> </h4>
</span>
</div>
<?php }
$participants = get_field( 'conversation_participants', $the_query->ID );?>
<div class='mvp-attendees'>
<span class='small-heading'>Participants :</span> <?php
$number_participants = count($participants);
$participants_left = $number_participants - 4;
$tmp = 0;
foreach($participants as $participant) {
if ( $tmp < 4 ){
echo $participant['user_avatar'];
}
$tmp += 1;
}
if($participants_left < -1){?>
<span> <?php echo sprintf('No participants :('); ?> </span> <?php
}elseif ($participants_left == 0){ ?>
<span> <?php echo sprintf(''); ?> </span> <?php
}elseif ($participants_left > 0){ ?>
<span> <?php echo sprintf('and %s others are coming',$participants_left); ?> </span> <?php
}
?>
</div>
</div>
<?php endwhile; ?>
</div><?php
wp_reset_postdata();
Все остальные данные запрашиваются надлежащим образом, за исключением местоположения событиякоторый я могу найти в объекте запроса.Поэтому я использовал заполнители, чтобы указать, где бы я хотел их разместить