Knowledgebase: Coding / Scripting
How To Add Custom Header, Footer, Sidebar On Different Categories
Posted by Modestas J on 21 June 2012 01:26 PM

Probably we have seen lots of WordPress websites with customized header, footer and sidebar on different categories pages. In this article, we will explain how to make those customizations for our blog or website.

Firstly, we will add custom header. Go ahead and open WordPress theme "index.php" file. Then find a line "get_header(); ?>" and replace it with the following lines:

get_header('category');
} else {
get_header();
} ?>

The code above means, if the visitor opens category named "category", then WordPress will execute file "header-category.php". If it doesn't exist, then default header will be displayed.

To add custom sidebar to category page, look for the line that says "get_sidebar(); ?>" and replace it with the following lines.

{ get_sidebar('category'); }
else { get_sidebar(); } ?>

If the selected category will be named "category", WordPress will run file "sidebar-category.php".

Finally, custom footer can be added by replacing line "get_footer(); ?>" with the lines below.

{ get_footer('category'); }
else { get_footer(); } ?>

Remember to replace word "category" with chosen category name.

The Best Web Hosting

(0 vote(s))
This article was helpful
This article was not helpful

Comments (0)
Post a new comment
 
 
Full Name:
Email:
Comments:
CAPTCHA Verification 
 
Please enter the text you see in the image into the textbox below. This is required to prevent automated registrations and form submissions.

Help Desk Software by Kayako Fusion