おはようございます、
カスタム投稿タイプ(Products)を作成し、そのカスタム投稿タイプに対して、Advanced CustomFieldプラグインを使用してカスタムフィールド(featured_product)を作成しました。カスタムフィールドを作成したときは、True/Falseフィールドタイプを使用して作成しました。
features_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(); ?>
問題は、1つの投稿しか返さないことですが、3つの投稿が注目されているとチェックされています。
私はここで何が間違っているのですか?
どうもありがとう!