关系字段ACF多种帖子类型

问题描述 投票:0回答:0

我正在尝试在两种帖子类型之间进行查询,以构建一个显示 05 新闻的页面。此查询将获取新闻名称,帖子类型为“post”,以及撰写新闻的记者的姓名以及帖子类型为“journalist”的照片。我在 ACF 中使用关系字段。我已经习惯使用 ACF,但是,这是我第一次使用关系字段。我似乎无法让信息出现。有人能帮我吗?我设法组装了下面的代码,但我有点迷失了,我在这个主题的几个地方进行了搜索,但我无法理解。这是我在下面编写的代码:

<!--Start Relationship-->
                       <?php 
                        $ids = get_field('notices', false, false);
                        $query = new WP_Query(array(
                            'post_type'         => 'posts',
                            'posts_per_page'    => 5,
                            'post_status'       => 'any',
                        ));
                      ?>
<!--End relationship-->
                        <div class="col-3"><img src="<?php the_field(‘photo') ?>" class="photo"></div>
                        <div class="container-reporter col-8">
<div class="name-reporter"><?php echo the_title(); ?></div>  (name reporter )                           <div class="key-notice"><?php the_field(‘key_notice') ?></div>                            <div class="text-reporter"><?php echo mb_strimwidth( get_the_title(), 0, 60, '...' ); ?></div>  (title notice)
                       </div>

我需要帮助来完成使用带有 ACF 关系字段的两种类型的帖子类型构建查询。

wordpress advanced-custom-fields
© www.soinside.com 2019 - 2024. All rights reserved.