首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如果WordPress页面ID =案例研究ID,则不显示单个案例研究

如果WordPress页面ID =案例研究ID,则不显示单个案例研究
EN

Stack Overflow用户
提问于 2019-11-21 22:38:51
回答 1查看 20关注 0票数 0

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

正如您在img中看到的,我正在进行垃圾车案例研究,并且仍然在页面的“其他案例研究”部分中再次被推荐。我想排除在个人案例研究页面上被拉入“其他案例研究”部分的垃圾车案例研究。如果我在其他个人案例研究页面上,情况也是如此。

代码语言:javascript
复制
<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>
EN

回答 1

Stack Overflow用户

发布于 2019-11-21 22:50:11

代码语言:javascript
复制
'post__not_in' => array (get_the_ID()),
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/58977465

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档