Du musst dich anmelden um Beiträge und Themen zu erstellen. Einloggen · Registrieren

Easy Display of Custom Headers, Footers, and Sidebars

WordPress 2.7 includes new functionality that makes it super-easy to include custom headers, footers, and sidebars into your theme. Normally, you include the default files with the following tags:

<?php get_header(); ?>

<?php get_sidebar(); ?>

<?php get_footer(); ?>

These will include the files named “header.php”, “sidebar.php”, and “footer.php”, respectively.

Now, to include alternate versions of these files, simply include the name of the file as a parameter in its associated tag. Here is an example that should illustrate the idea:

<?php get_header('custom-header'); ?>

<?php get_sidebar('custom-sidebar'); ?>

<?php get_footer('custom-footer'); ?>

These will include the files named “custom-header.php”, “custom-sidebar.php”, and “custom-footer.php”, respectively.

We can now use this new functionality to get fine-grained with includes. For example, if we wanted to display a custom footer for the “Bananaz” category, we could use the following code:

<?php if is_category('Bananaz') {
} else {
} ?>

Source: WordPress Codex