我正在尝试拉入/选择一个不同的案例研究,以显示页面ID =案例研究ID。原因是,目前我在个人案例研究的底部有一个内容块,用于阅读我编写的其他案例研究。尽管如此,我目前推荐的案例研究与我目前所在的案例研究页面相同,因为它是最新发布的案例研究。您可以在下面查看:

正如您在img中看到的,我正在进行垃圾车案例研究,并且仍然在页面的“其他案例研究”部分中再次被推荐。我想排除在个人案例研究页面上被拉入“其他案例研究”部分的垃圾车案例研究。如果我在其他个人案例研究页面上,情况也是如此。
<div class='col-sm-10 col-sm-offset-1'>
<?php $case_study_posts = array(
'post_type' => 'case_study',
'showposts' => 2
);
$case_study = new WP_Query( $case_study_posts );
if ( $case_study->have_posts() ) : while ( $case_study->have_posts() ) : $case_study->the_post(); ?>
<?php $case_study_id = get_the_ID(); ?>
<?php if($page_id = $case_study_id): ?>
<article class="col-sm-6">
<a href="<?php the_permalink(); ?>"><img src="<?php the_field('case_study_featured_img'); ?>" alt="" /></a>
<h3><a href="<?php the_permalink(); ?>"><?php the_field('case_study_heading'); ?></a></h3>
<?php the_field('case_study_excerpt'); ?>
<a href="<?php the_permalink(); ?>"><button class="btn btn-dark">Read Case Study</button></a>
</article>
<?php endif; ?>
<?php endwhile; endif; ?>
</div>发布于 2019-11-21 22:50:11
'post__not_in' => array (get_the_ID()),https://stackoverflow.com/questions/58977465
复制相似问题