比较两种帖子类型的ACF以创建查询

时间:2017-01-11 06:38:39

标签: php wordpress custom-post-type advanced-custom-fields

我需要比较两种帖子类型的ACF来创建查询。

我有一个名为'问题'的CPT,并在此页面上有一个日期选择器。 我正在使用我的其他帖子类型的默认帖子类型,并且我在此页面上也有一个日期选择器。

我想在 issues-single.php 页面上创建一个查询,如果两个帖子类型的日期匹配,它将引入默认帖子。

例如:如果我的问题 - 单页上的日期选择器是2017年1月,我想查询所有在日期选择器中选择了相同日期的defualt帖子

这是我到目前为止的代码,但我只是出现“页面无效”错误。

<?php
$current_page_year = get_field('issue_date');
$args = array(
    'post_type' => 'post',
    'post_per_page' => '1',
    'meta_key' => 'article_date',
    'meta_value' => "$current_page_year",
);
$my_query = new WP_Query($args);
if ($my_query->have_posts())
{
    while ($my_query->have_posts()) : $my_query->the_post();
        ?>
        <div class="small-12 medium-8 columns" id="mag-feature">
            <p class="mag-cat"><?php the_category(', ') ?></p>
            <a href="<?php the_permalink() ?>"><?php the_post_thumbnail('quorum-featured'); ?></a>
            <div class="mag-news-content clearfix">
                <a href="<?php the_permalink() ?>"><h2><?php the_title(); ?></h2></a>
                <p><?php the_excerpt(); ?></p>
                <a class="mag-read-more" href="<?php the_permalink() ?>">Read More</a>
            </div>
        <?php endwhile;
        wp_reset_query();
        ?>
        </div><!-- end #mag-feature -->

0 个答案:

没有答案