Php Don';如果WordPress页面ID=案例研究ID,则不显示单个案例研究

Php Don';如果WordPress页面ID=案例研究ID,则不显示单个案例研究,php,wordpress,Php,Wordpress,我正在尝试拉入/选择一个不同的案例研究,以显示页面ID=案例研究ID。原因是目前我在个人案例研究底部有一个内容块,用于阅读我编写的其他案例研究。尽管如此,我目前还是被推荐使用与我目前所在的案例研究页面相同的案例研究,因为它是最新发布的案例研究。您可以在下面查看: 正如你在img中所看到的,我正在进行垃圾车案例研究,并且仍然在页面的“其他案例研究”部分再次被推荐。我想在“个别案例研究”页面上排除“其他案例研究”部分中的垃圾车案例研究。如果我在另一个个案研究页面上,情况也是如此 <div cl

我正在尝试拉入/选择一个不同的案例研究,以显示页面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>

您可以在Wp\u查询的数组中添加
“post\u not\u in”=>获取\u ID,
。请提供不仅仅是代码的答案。相反,对代码的解释和它为什么能解决这个问题的分解是最有益的。
'post__not_in' => array (get_the_ID()),