固定ページ内にカスタム投稿をターム別に表示したい
-
カスタム投稿aaa、タクソノミーbbb、それに属するタームがxxx,yyy,zzzとあります。
固定ページ、page-test.phpにて下記のように同じコードのターム部分をxxx,yyy,zzzと書き換えて3回記述しました。<?php $args = array( 'numberposts' => -1, 'post_type' => 'aaa', 'taxonomy' => 'bbb', 'term' => 'xxx', 'relation' => 'OR' ); $customPosts = get_posts($args); if($customPosts) : foreach($customPosts as $post) : setup_postdata( $post ); ?> <!--ここに出力内容--> <?php endforeach; ?> <?php endif; wp_reset_postdata(); ?> ~ 中 略 ~ <?php $args = array( 'numberposts' => -1, 'post_type' => 'aaa', 'taxonomy' => 'bbb', 'term' => 'yyy', 'relation' => 'OR' ); $customPosts = get_posts($args); if($customPosts) : foreach($customPosts as $post) : setup_postdata( $post ); ?> <!--ここに出力内容--> <?php endforeach; ?> <?php endif; wp_reset_postdata(); ?> ~ 中 略 ~ <?php $args = array( 'numberposts' => -1, 'post_type' => 'aaa', 'taxonomy' => 'bbb', 'term' => 'zzz', 'relation' => 'OR' ); $customPosts = get_posts($args); if($customPosts) : foreach($customPosts as $post) : setup_postdata( $post ); ?> <!--ここに出力内容--> <?php endforeach; ?> <?php endif; wp_reset_postdata(); ?>
すると、なぜか一番上のxxxの投稿しか表示されません。
何か間違っているのか、他に書き方があるのか、どなたかアドバイスいただけないでしょうか。
7件の返信を表示中 - 1 - 7件目 (全7件中)
7件の返信を表示中 - 1 - 7件目 (全7件中)
- トピック「固定ページ内にカスタム投稿をターム別に表示したい」には新たに返信することはできません。