サポート » テーマ » カテゴリーページに全ての記事が表示されてしまう

  • カテゴリーアーカイブのページに、別のカテゴリーの記事も一緒くたになって
    表示されてしまいます。

    一度テーマを「Twenty Eleven」にして確認したところ
    カテゴリー別にきちんと表示されたので
    おそらく今使用しているテーマが原因なのでは、と思います。

    以下がcategory.phpのコードとなるのですが
    どこを修正すればよいのでしょうか?

    <?php get_header(); ?>
    
    <div id="container">
    
    	<div id="content" class="wide">
    
            <div class="postarea">
    
            	<h1><?php the_category(', '); ?></h1>
    
                <?php $wp_query = new WP_Query(array('showposts'=>'12','paged'=>$paged)); ?>
                <?php $post_class = 'first'; ?>
    			<?php if($wp_query->have_posts()) : while($wp_query->have_posts()) : $wp_query->the_post(); ?>
    			<?php $meta_box = get_post_custom($post->ID); $video = $meta_box['custom_meta_video'][0]; ?>
                <?php global $more; $more = 0; ?>
    
                <div class="portfolio one <?php echo $post_class; ?>">
    
    				<?php
    	                if ('first' == $post_class){
    	                  $post_class = 'second';
    	                }elseif ('second' == $post_class){
    	                  $post_class = 'third';
    	                }else{
    	                  $post_class = 'first';
    	                }
    	            ?>	
    
    	            <?php if ( $video ) : ?>
    	          		<div class="portfoliovideo one"><?php echo $video; ?></div>
    				<?php else: ?>
    	                <div class="portfolioimg one"><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_post_thumbnail( 'portfolio-3' ); ?></a></div>
    	            <?php endif; ?>
    
    	            <div class="portfoliotitle one">
    	                <h2><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h2>
    	                <?php the_excerpt(); ?>
    	            </div>
    
    	        </div>
    
    			<?php endwhile; ?>
    
                <div class="pagination">
                	<?php if (function_exists("number_paginate")) { number_paginate(); } ?>
                </div>
    
                <?php else : // do not delete ?>
    
                <h3><?php _e("Page not Found"); ?></h3>
                <p><?php _e("We're sorry, but the page you're looking for isn't here."); ?></p>
                <p><?php _e("Try searching for the page you are looking for or using the navigation in the header or sidebar"); ?></p>
    
    			<?php endif; // do not delete ?>
    
    		</div>
    
    	</div>
    
    </div>
    
    <?php get_footer(); ?>
1件の返信を表示中 - 1 - 1件目 (全1件中)
  • モデレーター jim912

    (@jim912)

    rujpさん、こんにちは。

    WP_Queryの存在意義がちょっとわかりません。
    必要な場合でも、関数リファレンスのWP_Queryを理解するようにしてください。

    それとは別に、the_categoryは個別の記事の所属カテゴリーを表示するものなので、カテゴリー名を表示するなら、single_cat_titleの方が適当です。

1件の返信を表示中 - 1 - 1件目 (全1件中)
  • トピック「カテゴリーページに全ての記事が表示されてしまう」には新たに返信することはできません。