Get the Official WPSaviour App Now!

BlogThemes

Easily Add Custom Header, Footer, or Sidebar for Each Category

Did you ever see WordPress blogs which have a separate header for various classes? On this tutorial we’ll share a easy snippet that you need to use so as to add customized header, footer, and even sidebar for every WordPress class.

To name a specific header, you will want to open your index.php and change your regular header code with this one:

<?php if (is_category(‘Running a blog’)) {
get_header(‘running a blog’);
} else {
get_header();
} ?>

This code above is mainly telling WordPress that if somebody opens the class referred to as “Running a blog” then WordPress must show a file referred to as header-blogging.php if it exist. If it doesn’t exist, or if the class shouldn’t be running a blog, then WordPress shows the default header file.

To get a separate sidebar for every all you must do is add the next code:

<?php if (is_category(‘Running a blog’)) {
get_sidebar(‘running a blog’);
} else {
get_sidebar();
} ?>

The code above will search for sidebar-blogging.php to exchange the default footer file if the class is Running a blog.

To get a separate footer for every class all you must do is add the next code:

<?php if (is_category(‘Running a blog’)) {
get_footer(‘running a blog’);
} else {
get_footer();
} ?>

The code above will search for footer-blogging.php to exchange the default footer file if the class is Running a blog.

Download The WPSaviour App Now

Related posts
Beginner’s GuideBlogShowcase

7 Best Shopify Alternatives in 2020 (Cheaper and More Powerful)

Beginner’s GuideBest WordPress PluginsBlog

14 Best AI Chatbots Software for Your Website (Comparison)

Beginner’s GuideBlogTips

Magento vs WooCommerce – Which one is Better? (Comparison)

Beginner’s GuideBlogTips

12 Best Calculator Plugins for Your WordPress Site

Sign up for our Newsletter and
stay informed

Leave a Reply

Your email address will not be published.

Fear Of Missing Out?

Sign up with your email address to receive WordPress tips and updates
SUBSCRIBE NOW
Terms and Conditions apply
close-link
Click Me