
Originally Posted by
Martijn
Thanks for your replies.
I'm using it already, it's for displaying PHP in a post.
That's exactly what I was looking for, thanks!
I use this tag, also. Here's my example script (inside the loop, before the post stuff), in context:
PHP Code:
<?php if(is_archive()) : ?>
<?php $post = $posts[0]; // Hack. Set $post so that the_date() works. ?>
<?php if (is_category()) { /* If this is a category archive */ ?>
<div class="cat-subscribe-feed">
<a href="<?php bloginfo('url'); ?>/category/<?php $cat = get_the_category(); $cat = $cat[0]; echo $cat->category_nicename;?>/feed/">
<img src="<?php bloginfo('template_directory'); ?>/images/subscribewide.jpg" width="120px" height="29" alt="Subscribe to the <?php echo single_cat_title(); ?> category feed" />
<?php echo single_cat_title(); ?> category feed</a>
</div>
<h2 class="pagetitle">
<?php echo single_cat_title(); ?>
</h2>
<div class="cat-description">
<?php echo category_description(); ?>
</div>
<?php } elseif (is_tag()) { /* If this is a tag archive */ ?>
<div class="cat-subscribe-feed">
<a href="<?php echo get_tag_feed_link($wp_query->get('tag_id'), 'rss2'); ?>">
<img src="<?php bloginfo('template_directory'); ?>/images/subscribewide.jpg" width="120px" height="29" alt="Subscribe to the <?php echo single_tag_title(); ?> tag feed" />
<?php echo single_tag_title(); ?> tag feed</a>
</div>
<h2 class="pagetitle">
<?php echo single_tag_title(); ?>
</h2>
<div class="cat-description">
<?php
echo tag_description();
?>
</div>
<?php } else {
if (is_search()) { /* If this is a search */ ?>
<h2 class="pagetitle">Search Results</h2>
<?php } ?>
<?php } ?>
<?php endif ?>
Here's the bit specific to categories:
PHP Code:
<?php if (is_category()) { /* If this is a category archive */ ?>
<div class="cat-subscribe-feed">
<a href="<?php bloginfo('url'); ?>/category/<?php $cat = get_the_category(); $cat = $cat[0]; echo $cat->category_nicename;?>/feed/">
<img src="<?php bloginfo('template_directory'); ?>/images/subscribewide.jpg" width="120px" height="29" alt="Subscribe to the <?php echo single_cat_title(); ?> category feed" />
<?php echo single_cat_title(); ?> category feed</a>
</div>
<h2 class="pagetitle">
<?php echo single_cat_title(); ?>
</h2>
<div class="cat-description">
<?php echo category_description(); ?>
</div>
<?php }
(The first part builds a link for the feed for the displayed category)
And note that it can also be used for tag pages:
PHP Code:
<?php } elseif (is_tag()) { /* If this is a tag archive */ ?>
<div class="cat-subscribe-feed">
<a href="<?php echo get_tag_feed_link($wp_query->get('tag_id'), 'rss2'); ?>">
<img src="<?php bloginfo('template_directory'); ?>/images/subscribewide.jpg" width="120px" height="29" alt="Subscribe to the <?php echo single_tag_title(); ?> tag feed" />
<?php echo single_tag_title(); ?> tag feed</a>
</div>
<h2 class="pagetitle">
<?php echo single_tag_title(); ?>
</h2>
<div class="cat-description">
<?php
echo tag_description();
?>
</div>
<?php }
(Likewise, the first part builds the RSS feed link for the tag. Just skip down to the H2 class="pagetitle" and following, for displaying just the Category/Tag title, and description.)