Home > categories > Different header for each category

Different header for each category

June 12Hits:1
Advertisement

I'm working on a project where each category should have a custom header page. Any suggestions? I'm just looking for some direction on how to accomplish this.

Answers

Use the is_category() condtional statement

if(is_category('category-a-slug')){
    get_header('a');
}elseif(is_category('category-b-slug')){
    get_header('b');
}

Install the plugin Taxonomy Images. In your header.php check if you are in a category archive and if an image exists for that category. Then use that instead of the default image.

You can use custom templates for different categories. When displaying a category archive, WordPress will check for these files in order:

  1. category-{slug}.php
  2. category-{id}.php
  3. category.php
  4. archive.php
  5. index.php

Read more at the WordPress Codex



If you prefer to use the one category.php template, we can load custom header.php files based on the category's ID. Replace the call to get_header() in category.php with the following code:

global $wp_query;
get_header( 'category-' . get_query_var('cat') );

WordPress will then look for header-category-{category_id}.php and load that file if found. Otherwise, header.php will be loaded as normal.

Related Articles

  • Can you write to the category field in the event log?July 28

    I've written a simple batch script that watches some services and regularly restarts them. I've used the eventcreate command to write to the Windows event log, which seems like a good way of logging my actions, but I notice that the 'category' field

  • How to create an Outlook rule to assign a category to emails from contacts that have a specific category assigned?

    How to create an Outlook rule to assign a category to emails from contacts that have a specific category assigned?November 26

    How can I create an rule in Outlook which does the following when an email arrives: Check if the sender is in my contacts Check if the contact has a specific category (e.g. Work) assigned Assign that (Work) or maybe some other category (e.g. Importan

  • Mysql category queryDecember 16

    I have a query which gets rows by category. A sample query is Ex. Select * from db where category = 14 Anybody have an idea or suggestions on how to optimize this so that the query can run faster? --------------Solutions------------- Well you have a

  • Is there a way to batch process Outlook contacts via category?

    Is there a way to batch process Outlook contacts via category?February 10

    I would like to select the contacts in a category and switch them to another category. Can this be automated? --------------Solutions------------- This can be achieved by doing the following: Open your Contacts folder View -> Current View -> By Cate

  • Windows Internet Explorer 8 Dynamic Installer category in WSUSMay 11

    I'm new to WSUS and I'm in the process of setting up a WSUS server. I'm wondering what is meant by the "Windows Internet Explorer 7/8 Dynamic Installer" category under "Under Products And Classifications"? Will this allow me to push ou

  • What is a good web app for tracking anything (not specific to one category)? July 8

    Last year, Wired Magazine published a seried of articles called "Living by the Numbers", which explored the advantages of tracking personal data to help reach goals in the areas of excercise, health, and nutrition. This got me thinking that trac

  • eShop product urls SEO, with or without category folderJuly 28

    What product url is better from SEO perspective for an eShop www.site.com/main-category/sub-category/sub-category2/product-name.html www.site.com/products/product-name.html www.site.com/product-name.html Some people state that the last one since you

  • Deleting the Uncategorized CategoryAugust 5

    I like to categorize all my posts. Is there a way that I can delete this category ? If not Why ? --------------Solutions------------- To delete the "Uncategorized" category: Use the category dashboard under Posts > Categories to create a seco

  • Graphs with Google Spreadsheets - collapse data into one 'category'

    Graphs with Google Spreadsheets - collapse data into one 'category'August 25

    I have a set of data which is similar to the following: Groceries 5.00 Groceries 14.75 Groceries 6.37 Dinner Out 43.50 Dinner Out 15.00 I'd like to be able to use this data to create some graphs, such that (in this case) I'd have two categories, and

  • What are the most over-saturated iPhone App category/markets? September 5

    I'm considering learning iPhone development and Objective C but don't want to avoid developing something for the most saturated markets and app categories. What categories should I avoid? Are there too many dating applications, or should I just stick

  • How do I get my wp_nav_menu single category page to highlight the parent?September 7

    With the new wp_nav_menu system, it is possible to add a category as a menu item, so in my example I have a 'news' category, which is a submenu item of 'About'. About (page) --news (category) --history (page) --contact us (page) The menu highlighting

  • include full category hierarchy in url or only the "leaf"?September 8

    I'm currently redesigning a site that organizes information into categories. Some of these categories contain subcategories (and some of those contain even more subcategories). I'm trying to decide between the following url structures for the resulti

  • Display posts links from a category group by yearSeptember 11

    I want to display posts links from a category group by year. Group by year becouse by default wordpress repeat the date for each post. I try use a code but I got all post in current year. How can I do it? Example I want to do: 2010 post link 20 post

  • How do I restrict a Google search to a certain category?September 15

    I work with the programming language Scala. Unfortunately the name is also used in many other contexts. In Google Insights I can restrict the search to a certain category. In the filter section I can choose the category Computer & Electronics / Progr

  • How to make a category page the blog home page?September 15

    I want to use a category page as the home page of my blog. Is that possible and how can I do it? It tried it with a .htacces rewrite rule but that didn't worked. --------------Solutions------------- Update Eliminating all of the other solutions, ther

  • Need advice converting category assignments to custom post meta valuesSeptember 16

    Before I found out about the ability to add a meta box (with custom post meta selections) to the page and post editor, I was (and still am to a degree) using categories to define custom post meta. For example, to make a post nofollow, or noindex, I c

  • How do I make the category template display full posts instead of partial posts?September 19

    I'm using Wordpress 3.0.1 with the Twenty Ten theme. I'm trying to change the way the posts in the Category view are displayed (i.e. by going to a url like mywebsite.com/category/mycategory). Currently the posts in the Category view just show the fir

  • Any built-in function to associate a post to category through a plugin?September 19

    I have a post ID and I'm just trying to find a function ( I was thinking of something similar to wp_update_post() ) where I can just pass a post ID and maybe a category ID or slug and have it associate the post to the category. Does that exist or hav

  • How to add a category or tag to media at upload time with the browser uploader?September 19

    I don't use WordPress very often... I hope this makes some sense :-) Is there a way to sort media files into categories? I want to give some order to the media that are being uploaded to the website, and 'attaching' media to a Post is not cutting it

  • Removing the number in a category slugSeptember 22

    I have a category that ends with -2, and there's no way I can change it back to the plain word. I know there are problems with numeric slugs, but this is just a word. I also know that a common answer is to look in the trash, but there's no trash for

Copyright (C) 2017 ceus-now.com, All Rights Reserved. webmaster#ceus-now.com 14 q. 0.294 s.