Introduction to categories
I wanted to add an introduction text to category pages. I already had a nice looking introduction text to the blog which only shows on the main page, so I thought I’d put the category descriptions in a similar box.
<!-- don’t show on a post’s page or monthly archives -->
<?php if (!$single && !$monthnum) { ?>
<div id="intro">
<!-- don’t show on category pages, either -->
<?php if(!$cat) { ?>
< Blog introduction >
<?php } ?>
<!-- show on category pages -->
<?php if ($cat) { ?>
<!-- single_cat_title(prefix,display) displays (with ‘true’ parameter) the category title -->
<h1><?php single_cat_title('',true); ?></h1>
<!-- category_description() alone doesn’t display it, that’s why you need to have the ‘echo’ there -->
<p><?php echo category_description(); ?></p>
<?php } ?>
</div>
<?php } ?>
Leave a Reply