0
0
Wordpressframework~5 mins

Header, footer, and sidebar templates in Wordpress

Choose your learning style9 modes available
Introduction

Headers, footers, and sidebars help organize your website. They keep important parts like menus and info in one place.

You want a menu at the top of every page.
You want contact info or copyright at the bottom of every page.
You want a list of links or widgets on the side of your pages.
You want to change the look of these parts without editing every page.
You want to add or remove items from these areas easily.
Syntax
Wordpress
<?php get_header(); ?>

<?php get_sidebar(); ?>

<?php get_footer(); ?>

Use get_header() to include the header template.

Use get_sidebar() to include the sidebar template.

Use get_footer() to include the footer template.

Examples
This loads the header and footer around your page content.
Wordpress
<?php get_header(); ?>
<!-- Page content here -->
<?php get_footer(); ?>
This loads a custom header file named header-custom.php.
Wordpress
<?php get_header('custom'); ?>
This loads a sidebar file named sidebar-blog.php.
Wordpress
<?php get_sidebar('blog'); ?>
Sample Program

This example shows a simple page that includes the header at the top, the sidebar on the side, and the footer at the bottom. The main content is between them.

Wordpress
<?php
// In your theme's index.php or page template
get_header();
?>
<main>
  <h1>Welcome to My Website</h1>
  <p>This is the main content area.</p>
</main>
<?php
get_sidebar();
get_footer();
?>
OutputSuccess
Important Notes

Header, footer, and sidebar files are usually named header.php, footer.php, and sidebar.php.

You can create multiple versions by adding a suffix, like header-home.php, and call it with get_header('home').

These templates help keep your site consistent and easier to update.

Summary

Headers, footers, and sidebars are reusable parts of your WordPress theme.

Use get_header(), get_sidebar(), and get_footer() to include them.

They make your site organized and easier to maintain.