我有一个从数据库获取自定义帖子类型的循环现在,当我转到页面时,数据不会显示,但当我刷新页面2次时,数据显示器是代码:
<div class="expertise-menu">
<?php
echo get_the_id();
$args = array(
\'posts_per_page\' => -1,
\'post_type\' => \'syllabus\',
array(
\'key\' => \'related_expertise\',
\'compare\' => \'LIKE\',
\'value\' => get_the_id()
)
);
$syllabus = new WP_Query($args);
if($syllabus->have_posts()) {
while( $syllabus->have_posts()) {
$syllabus->the_post();
?>
<div class="expertise-menu__box" data-expertise="<?= get_field("related_expertise")[0]->post_name; ?>">
<input type="checkbox" class="expertise-menu__input"
name="<?= get_field("related_expertise")[0]->post_name; ?>" id="<?= get_the_id(); ?>">
<label for="<?= get_the_id(); ?>" class="expertise-menu__label">
<span class="svg-box">
<svg viewBox="0 0 100 100">
<path class="svg-rect"
d="M82,89H18c-3.87,0-7-3.13-7-7V18c0-3.87,3.13-7,7-7h64c3.87,0,7,3.13,7,7v64C89,85.87,85.87,89,82,89z" />
<polyline class="svg-check" points="25.5,53.5 39.5,67.5 72.5,34.5 " />
</svg>
</span>
<a href="<?= get_the_permalink(); ?>" class="expertise-menu__link">
<span class="expertise-menu__text"><?= get_the_title(); ?></span>
<span
class="expertise-menu__text expertise-menu__text--sub"><?= get_field(\'syllabus_code\'); ?></span>
</a>
<span class="expertise-menu__arrow">
<svg width="1em" height="1em" viewBox="0 0 16 16" class="bi bi-chevron-right"
fill="currentColor" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd"
d="M4.646 1.646a.5.5 0 0 1 .708 0l6 6a.5.5 0 0 1 0 .708l-6 6a.5.5 0 0 1-.708-.708L10.293 8 4.646 2.354a.5.5 0 0 1 0-.708z" />
</svg>
</span>
</label>
</div>
<?php } wp_reset_query(); ?>
<?php } ?>
</div>
<!-- Expertise Menu END -->