Top Ad unit 728 × 90

Easily Add Custom Header, Footer, or Sidebar on Different Categories

Did you ever come across a site that is using different header or sidebar for some categories? Well this is how you can accomplish that as well.
To call a particular header, you will need to open your index.php and replace your normal header code with this one:
1<?php if (is_category('Blogging')) {
2get_header('blogging');
3else {
4get_header();
5} ?>
This code above is basically telling WordPress that if someone opens the category called “Blogging” then WordPress needs to display a file called header-blogging.php if it exist. If it does not exist, or if the category is not blogging, then WordPress displays the default header file.
To get a separate sidebar for each all you need to do is add the following code:
1<?php if (is_category('Blogging')) {
2get_sidebar('blogging');
3else {
4get_sidebar();
5} ?>
The code above will look for sidebar-blogging.php to replace the default footer file if the category is Blogging.
To get a separate footer for each category all you need to do is add the following code:
1<?php if (is_category('Blogging')) {
2get_footer('blogging');
3else {
4get_footer();
5} ?>
The code above will look for footer-blogging.php to replace the default footer file if the category is Blogging.
Easily Add Custom Header, Footer, or Sidebar on Different Categories Reviewed by Unknown on 11:16 PM Rating: 5

No comments:

All Rights Reserved by Boca Raton Real Estate © 2014 - 2015
Powered By Blogger, Designed by Sweetheme

Contact Form

Name

Email *

Message *

Powered by Blogger.