Jan 11 ,11
create « »

Last post’s excerpt on category.php (WordPress, php)

<?php
	foreach((get_the_category()) as $category) 
	{ 
		$postcat= $category->cat_ID; 
		$catname =$category->cat_name;
	} 	

	query_posts("cat=$cat->cat_ID&posts_per_page=1");
?>
<a href="<?php the_permalink() ?>">
	<?php the_excerpt('more_link_text', strip_teaser, 'more_file'); ?>
</a>



	

This code snippet for wordpress works within category.php. It simply shows the last post’s excerpt in the current category
e.g. a picture or a meaningful text.

Leave a Reply

You must be logged in to post a comment.