お世話になっております。
カスタム投稿[class]、タクソノミー[classwork]を作成して、記事一覧を表示したいです。
カスタム投稿[class]は[archive-class.php]で正常に表示されています。
ですが、タクソノミーの記事一覧で記事が表示されません。
[taxonomy-classwork.php]
php
1<?php 2$args = array( 3 'post_type' => 'class', 4 'posts_per_page' => 6, 5 'tax_query' => array( 6 array( 7 'taxonomy' => 'classwork', 8 'field' => 'slug' 9 ) 10 )); 11$postslist = get_posts($args);?> 12<?php if( $postslist ) : foreach( $postslist as $post ) : setup_postdata( $post ); ?> 13 14表示する内容 15 16<?php endforeach; endif; wp_reset_postdata();?>
色んなサイトを見て記述の仕方なども変えたのですが、どれもダメです。
カスタム投稿[class]のexclude _From_Searchはfalseにしてます。
[archive-class.php]は以下です。
php
1<?php if (is_mobile()) { 2 $num = 6; } else { $num = 3; } 3 $args = array('post_type' => 'class','posts_per_page' => $num,); 4 $query = new WP_Query($args); 5 while ($query->have_posts()) : $query->the_post(); ?> 6 7表示する内容 8 9<?php endwhile; ?> 10<?php 11 if ($the_query->max_num_pages > 1) { 12 echo "<div class='pagenation'>"; 13 echo paginate_links( 14 array( 15 'base' => get_pagenum_link(1).'%_%', 16 'format' => 'page/%#%/', 17 'current' => max(1, $paged), 18 'total' => $the_query->max_num_pages, 19 'prev_next' => true, 20 'prev_text' => '<i class="fas fa-angle-left"></i> 前へ', 21 'next_text' => '次へ <i class="fas fa-angle-right"></i>', 22)); 23echo "</div>"; 24} 25wp_reset_postdata();?>
何が間違っているのでしょうか?
ご教授お願いします。
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。