WordPressのカテゴリページで、すべての記事の一覧を表示

Filed under PHP, wordpress

ブログのカテゴリページをちょっといじりました。

カテゴリに属する記事をすべてリスト表示するように。

たとえば、このブログのAS3カテゴリなら、こんな感じで表示されます。

下のようなコードで記事一覧取得&リスト表示ができます。

<ul>
<?php
	// カテゴリを取得
	$cat_id = get_query_var('cat');
	$cat = get_category($cat_id);

	// カテゴリに属する記事の数を取得
	$show_number = $cat->category_count;

	// 記事の読み込み
	query_posts("{$query_string}&showposts={$show_number}");

	// ループで記事をリスト表示
	if (have_posts ()):while (have_posts ()): the_post();
?>
<li><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></li>
<?php
	endwhile;
	endif;
?>
</ul>

Post a Comment

Your email is never published nor shared.