Jan 12 ,11
create « »

Category title and Posts included (WordPress)

<div  id="subnavigation" >
<?php
	$temp_category = single_cat_title('',false);
	if (!empty($temp_category)){
	// give index
?>
<h2><?php single_cat_title(); ?></h2>
	<?php if ($posts) : foreach ($posts as $post) : start_wp(); ?>
		<h3><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h3>
	<?php endforeach; else: ?>
	<?php _e('Sorry, no posts matched your criteria.'); ?>
	<?php endif; ?>
	<?php
}else{ // give details or single post
?>
...... code 4 normal post overview
<?php
}
?>
</div>
	

This code snippet for wordpress works within the category.php. It writes the current category and below a list of the posts included.

Example:
Subcategory A
Post 4 of Subcategory A
Post 3 of Subcategory A
Post 2 of Subcategory A
Post 1 of Subcategory A

Leave a Reply

You must be logged in to post a comment.