0
我使用Adv Custom Fields插件创建了一个字段,该插件允许用户选择页面所在的部分(如类别)。在每个页面上,我想显示一个侧栏,其中显示了具有相同部分的页面列表。我试图使用meta_query,但没有得到任何结果。如果有办法做,我也想先显示父页面。这里是我的查询:Wordpress meta_query不显示结果
<ul class="test-menu">
<?php
$section = get_field('section');
$args = array(
'meta_query' => array(
array(
'key' => 'section',
'value' => $section
)
)
);
$loop = new WP_Query($args);
while ($loop->have_posts()) : $loop->the_post();
?>
<li><a href="<?php echo get_permalink(); ?>"><?php the_title(); ?></a></li>
<?php endwhile; ?>
<?php wp_reset_query(); ?>
</ul>