Hi all.
I am trying to enable unique page descriptions for all pages, categories, tags and posts.
I use this code in header.php to pull out the description based upon the content type (home, category, tag, month, post):
<meta name="description" content="<?php if ( (is_home()) || (is_front_page()) ) {
echo ('homepage description goes here');
} elseif(is_category()) {
echo category_description();
} elseif(is_tag()) {
echo '-tag archive page for this blog' . single_tag_title();
} elseif(is_month()) {
echo 'archive page for this blog' . the_time('F, Y');
} else {
echo get_post_meta($post->ID, "custompagedescription", true);
}?>">
This works fine for all standard content but this doesn't seem to be working for a custom category for some reason; instead, it shows the description for the most recent post within the custom category.
If I try using: <?php echo category_description() ?> somewhere else on the page, then this does pull out the description for the custom category.
I can only assume that the code above is not identifying the custom category as a category and so is defaulting to showing the description for the most recent post.
Anyone know why this is? If this is the case, then how would I include an elseif for a custom category?
Thanks for your help.