2
我創建了一個自定義帖子類型 - 產品 - 併爲該自定義帖子類型創建了一個自定義字段 - featured_product - 使用高級自定義字段插件。 當我創建自定義字段時,我使用了True/False字段類型。
我想顯示這些產品帖子,其中的feature_product複選框 被選中。
這是我當前的代碼:
<?php query_posts(array(
'posts_per_page' => 3,
'post_type' => 'products',
'orderby' => 'post_date',
'paged' => $paged
)
); ?>
<?php if (have_posts()) while (have_posts()) : the_post(); ?>
<?php if(get_field('featured_product')){ ?>
<div id="post-<?php the_ID(); ?>" class="cpt">
<h2><?php the_title(); ?></h2>
<?php
if (has_post_thumbnail()) {
the_post_thumbnail('excerpt');
}
?>
<?php the_excerpt(); ?>
<ul class="prod_detail">
<li><a href="<?php the_field('product_detail_page'); ?>">Learn More</a></li>
<li><a href="<?php the_field('purchase_link'); ?>">Place Order</a></li>
</ul>
</div>
<?php } ?>
<?php endwhile; ?>
<?php wp_reset_query(); ?>
的問題是,它只返回一個職位 - 但我有3個職位檢查爲被功能。
我在這裏做錯了什麼?
非常感謝!