wordpress tutorial for add custom header, footer, or sidebar for different categories in WordPress. we have given simple conditinal code which need to use in your theme file.
add custom header to different categories in WordPress
If you want to add the different header for each category then use the following code in your index.php where “get_header()” method is called.
Create the Header-new_category.php file and put your header code in that file as per requirement.
For sidebar use this code:
<?php if (is_category(‘new_category’)) { get_header(' new_category '); } else { get_header(); } ?>
Create the Header-new_category.php file and put your header code in that file as per requirement.
For sidebar use this code:
<?php if (is_category('New_category')) { get_sidebar('new_category'); } else { get_sidebar(); } ?>
Create the sidebar-new_category.php file and put your sidebar code in that file as per requirement.
For Footer use this code:
<?php if (is_category('New_category')) { get_footer('new_category'); } else { get_footer(); } ?>
Create the footer-new_category.php file and put your footer code in that file as per requirement.
Wow, Purab, thanks for all the great info on your site.
“custom header to different categories” is just what I was looking for. I’m good in html old school, but not php and wordpress. Trying to convert my old pages to wordpress blog.
Boy, everything was so easy with html, but wordpress..sigh!!
Unbelieable that you need to have the same header for the entire blog, and no functionallity built in to change, that’s a nightmare!
Fortunately I found you, but…I dont quite get it what to do and exactly what files to create.
Say I have category 1 and category 2, how do I implement the code?
and what new files do I create?
Thanks a lot.
You need two category header file as mentioned article.