Hello,
I'm working on a site where content is being filtered throughout the site using categories. The site owners are going to want to use a category as a blog, but then we're also using categories to filter out "news and announcements" and "featured home page items."
In order to make sure it's really clear where a user is, then, I needed to add the category title to the category page, and the single post page. However, I did not want it to appear in the date archive.
By the way, I'm using WordPress' built in navigation menu, so in order to point to a category page, all I did was add the category to the menu. Bam. Done. (unfortunately this means I couldn't set up a template page for the category easily, but oh well).
I attached this to the navigation above, as that was the only hook I could find that appeared on the pages I wanted these titles to show up on.
Here's the code (most of which is grabbed from wordpress codex and forum):
//put blogtitle onto a single page
function blogtitle_on_single_page() {
if (!is_date()) {
?>
<h1><?php $categories = get_the_category(); foreach($categories as $category) {
$cat_name = $category->name;
if($cat_name != 'featured') echo '<a href="'.get_category_link($category->term_id).'">'.$cat_name . '</a> '; }
?></h1>
<?php }
}
add_action('thematic_navigation_above','blogtitle_on_single_page');