我正在尝试使用“ while”循环来遍历自定义帖子,但是由于某些原因,它不起作用。我需要显示每个帖子的图像和图像以及自定义字段,但是我感觉在启动循环时我做错了事。
<div class="brand-slider">
<?php
$args = array(
'post_type' => 'home_test',
'posts_per_page' => -1,
'orderby' => 'menu_order',
'order' => 'DSC',
);
$brand = get_posts($args);
while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
$thumbnail = get_the_post_thumbnail_url($post->ID, 'full');
$homelinkvalue = the_field( "home_brand_link" );
<div>
<a href="<?php echo get_field('home_brand_link'); ?>" target="_blank" ><img src="<?php echo $thumbnail; ?>"></a>
</div>
<?php endwhile; ?>
}
wp_reset_postdata();
?>
</div>