【发布时间】:2018-04-01 15:54:42
【问题描述】:
我尝试用一个变量请求显示一个事件的所有采访。 因此,在我的查询中,我询问所有帖子“evenement_associe”在哪里与页面的 id 相同。但我不知道为什么,查询是空的。 图片是文章的group字段。enter image description here
<?php
// args
$id_eventz = get_the_ID();
$args = array(
'post_type' => 'post',
'meta_key' => 'evenement_associe',
'meta_value' => $id_eventz
);
// query
$the_query = new WP_Query($args);
?>
<?php
if ($the_query) {
?>
<?php if ($the_query->have_posts()): ?>
<?php while ($the_query->have_posts()) : $the_query->the_post() ?>
<?php
$value_link=get_field('evenement_associe');
$id_article=get_the_ID();
$title_article=get_the_title($id_article);
?>
<ul>
<li>
<?php
?>
</li>
</ul>
<?php endwhile; ?>
<?php else: echo 'Aucun article encore réalisé pour cet évènement.'?>
<?php endif; ?>
<?php wp_reset_query(); // Restore global post data stomped by the_post().
//
} ?>
【问题讨论】:
标签: php mysql wordpress advanced-custom-fields