It is possible… except there is a more natural approach.
Use Category_Templates and have the information in it, either hard-coded or displayed by a call to a hidden Page or Post (e.g. with a plugin like get-a-post)
Can you please add a small demo code here so i can try out.
Create a new category.php and put this inside:
<?php get_header(); ?>
<!-- The Category's Description-->
<h1><?php the_category(' ', 'parent'); ?></h1>
<?php echo category_description(); ?>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
<?php the_time('j. F Y'); ?>
<?php the_excerpt('Read more »'); ?>
<?php endwhile; else: ?>Oops
<?php endif; ?>
<?php get_footer(); ?>
Actually, I just realized this is only half the answer.
This just displays the category description above the posts. Now the featured post requires more code. Either do 2 loops, the first one using
<?php query_posts('category_name=XYZ&showposts=1'); ?>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
etc. to display the first post of this category XYZ, then use a
<?php query_posts('category_name=XYZ&showposts=10&offset=1'); ?>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
etc. do list the rest of the posts excluding the first one (hence the “offset” parameter)
EDIT: okay, here’s the whole thing 🙂
<?php get_header(); ?>
<!-- The Category's Description-->
<h1><?php the_category(' ', 'parent'); ?></h1>
<?php echo category_description(); ?>
<!-- featured post -->
<?php query_posts('category_name=XYZ&showposts=1'); ?>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
<p><?php the_content(); ?></p>
<?php endwhile; else: ?>Oops<?php endif; ?>
<!-- the rest of the posts -->
<?php query_posts('category_name=XYZ&showposts=10&offset=1'); ?>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
<p><?php the_excerpt('Read more >'); ?></p>
<?php endwhile; else: ?>Oops<?php endif; ?>
<?php get_footer(); ?>
I’d like to use this, but I don’t want to hardcode in the category, I want to be the_category. Haven’t found the syntax for doing that.
This is the code I came up with to do Show a featured post for each category, with the remain posts in that section shown in excerpts:
<h1><?php echo(get_category_parents($cat, TRUE, ‘ » ‘)); ?></h1>
<em class=”catdescript”><?php echo category_description(); ?>
<?php $i = 1; ?>
<?php if (have_posts()) : while (have_posts()) : the_post(”); ?>
<h2>“><?php the_title(); ?></h2>
<p><?php the_time(‘F j, Y’); ?></p>
<?php if (1 == $i) : ?>
<p><?php the_content(); ?></p>
<?php else : ?>
<?php the_excerpt(‘Read more >’); ?>
<?php endif; ?>
<p>Posted by <?php the_author(); ?> | Filed Under <?php the_category(‘, ‘) ?> | <?php comments_popup_link(‘Leave a Comment’, ‘1 Comment’, ‘% Comments’); ?> <?php edit_post_link(‘(Edit)’, ”, ”); ?></p>
<?php $i++; ?>
<?php endwhile; else: ?>
<p><?php _e(‘Sorry, no posts matched your criteria.’); ?></p><?php endif; ?>
<p><?php posts_nav_link(‘ — ‘, __(‘« Previous Page’), __(‘Next Page »’)); ?></p>