Get a particular header, footer, or sidebar of wordpress

January 4, 2009 · Print This Article

Since WordPress 2.7, it is easier to choose which header, footer or sidebar file you want to include on your theme.

The following code will check if the reader is on the “WordPress” category. If yes, header-wordpress.php will be inclued, otherwise the default header will be used:


<?php if is_category('WordPress') {
get_header('wordpress');
} else {
get_header();
} ?>

You can also use that new functionality with footers and sidebars:

<?php get_footer('myfooter'); ?>

will include footer-myfooter.php

<?php get_sidebar('mysidebar'); ?>

will include sidebar-mysidebar.php


Your choice for site templates and wordpress themes

Comments

One Response to “Get a particular header, footer, or sidebar of wordpress”

  1. Posts about Wordpress 2.7 as of January 4, 2009 | The Lessnau Lounge on January 5th, 2009 10:25 am

    […] … .  I have been running WordPress 2.5 for a year, and the major shifts that have happened Get a particular header, footer, or sidebar of wordpress – livexp.net 01/04/2009 Since WordPress 2.7, it is easier to choose which header, footer or sidebar […]

Got something to say?

You must be logged in to post a comment.