taxonomy.phpの記事が表示されないのはなぜ?
-
○質問の主旨
下記のコードでtaxonomy.phpを記述していますが、
<!– コンテンツ –><div id=”content”>~</div>の間の記述が全く反映されず、
カスタム投稿で分類したカテゴリーが表示されません。
これはなぜでしょうか?詳しい方がいらっしゃいましたら、
ご教示願います。関連質問:カスタム分類とquert_posts()の引数について
○質問の補足
<!– コンテンツ –><div id=”content”>~</div>の間の記述は
全く反映されていないにも関わらず、
<!– サイドバー –><div id=”sidebar”>~</div>の記述は
そのまま反映されています。○コード1(taxonomy.php)
<?php get_header(); ?>
<div>
<?php $terminfo = get_term_by(‘slug’, $term, $taxonomy); ?>
</div><!-- コンテンツ --> <div id="content"> <p class="title"><?php echo $terminfo->name; ?></p> <?php query_posts('posts_per_page=2&order=DESC&' . $query_string); ?> <?php if(have_posts()): while(have_posts()): the_post(); ?> <div class="post"> <h2><?php the_title(); ?></h2> <?php the_content(); ?> </div> <?php endwhile; endif; ?> <?php get_template_part('pagenation'); ?> </div> <!-- サイドバー --> <div id="sidebar"> <ul> <li class = "widget"><h2>ニュースのカテゴリー</h2> <ul> <?php $myterms = get_terms('newscat'); ?> <?php foreach ($myterms as $myterm): ?> <li> <a href="<?php echo get_term_link($myterm->slug, 'newscat'); ?>"><?php echo $myterm->name; ?></a> </li> <?php endforeach;?> </ul> </li> <li class="widget"> <h2>最近のニュース</h2> <ul> <?php query_posts('post_type=news&posts_per_page=5'); ?> <?php if(have_posts()): while(have_posts()): the_post(); ?> <?php get_template_part('content','title'); ?> <?php endwhile; endif; ?> </ul> </li> </ul> </div> <?php get_footer(); ?>
○コード2(functions.phpの一部)
// ニュース記事の投稿タイプ register_post_type( 'news', array( 'label' => 'ニュース', 'hierarchical' => false, 'public' => true, 'has_archive' => true, 'supports' => array( 'title', 'editor' ), 'exclude_from_search' => true ) ); // ニュース記事を分類するカスタムタクソノミー register_taxonomy( 'newscat', 'news', array( 'label' =>'ニュースのカテゴリー', 'hierarchical' => true, ) );
7件の返信を表示中 - 1 - 7件目 (全7件中)
7件の返信を表示中 - 1 - 7件目 (全7件中)
- トピック「taxonomy.phpの記事が表示されないのはなぜ?」には新たに返信することはできません。