Bird
Raised Fist0
Wordpressframework~10 mins

Header and footer customization in Wordpress - Step-by-Step Execution

Choose your learning style10 modes available

Start learning this pattern below

Jump into concepts and practice - no test required

or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Concept Flow - Header and footer customization
Start WordPress Theme
Locate header.php & footer.php
Edit header.php
Add/Change HTML & PHP for header
Save header.php
Edit footer.php
Add/Change HTML & PHP for footer
Save footer.php
Refresh Website
See updated header & footer
End
This flow shows how WordPress loads header and footer files, how you edit them, save changes, and see updates on the website.
Execution Sample
Wordpress
<?php
// header.php snippet
?><header>
  <h1>My Site Title</h1>
</header>

<?php
// footer.php snippet
?><footer>
  <p>© 2024 My Site</p>
</footer>
This code adds a simple header with a site title and a footer with copyright text.
Execution Table
StepFile EditedActionCode ChangeEffect on Site
1header.phpOpen fileLocate header.php in theme folderReady to edit header
2header.phpAdd HTML<header><h1>My Site Title</h1></header>No visible change yet
3header.phpSave fileSave changesHeader updates on refresh
4footer.phpOpen fileLocate footer.php in theme folderReady to edit footer
5footer.phpAdd HTML<footer><p>© 2024 My Site</p></footer>No visible change yet
6footer.phpSave fileSave changesFooter updates on refresh
7BrowserRefresh pageReload websiteSee new header and footer
8EndNo more editsCustomization completeSite header and footer customized
💡 Customization stops after saving and refreshing to see changes.
Variable Tracker
VariableStartAfter header editAfter footer editFinal
header.php contentOriginal header code<header><h1>My Site Title</h1></header><header><h1>My Site Title</h1></header><header><h1>My Site Title</h1></header>
footer.php contentOriginal footer codeOriginal footer code<footer><p>© 2024 My Site</p></footer><footer><p>© 2024 My Site</p></footer>
Website displayOld header and footerHeader updated, footer oldHeader updated, footer updatedHeader and footer updated
Key Moments - 3 Insights
Why do changes in header.php not show up immediately after editing?
Because you must save the file and refresh the browser to see the updated header, as shown in steps 3 and 7 in the execution table.
Can I customize header and footer without touching PHP code?
Some themes offer settings in the WordPress dashboard, but direct customization usually requires editing header.php and footer.php files, as shown in the flow.
What happens if I delete header.php or footer.php?
The site may lose its header or footer display or show errors, so always back up files before editing.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution table, what is the effect on the site after step 2?
ANo visible change yet
BFooter shows copyright text
CHeader shows site title
DSite refreshes automatically
💡 Hint
Check the 'Effect on Site' column for step 2 in the execution table.
At which step do you see both header and footer updated on the website?
AStep 5
BStep 7
CStep 6
DStep 3
💡 Hint
Look for the step where the browser refreshes and shows both changes.
If you forget to save footer.php after editing, what will happen?
AFooter updates on refresh
BHeader disappears
CFooter remains unchanged
DSite crashes
💡 Hint
Refer to the importance of saving files before refreshing in the execution table steps 5 and 6.
Concept Snapshot
Header and footer customization in WordPress:
- Edit header.php and footer.php files in your theme folder.
- Add or change HTML/PHP code for header/footer content.
- Save files and refresh your website to see changes.
- Always back up files before editing.
- Changes appear only after saving and refreshing.
Full Transcript
In WordPress, the header and footer are controlled by separate files named header.php and footer.php inside your theme folder. To customize them, you open these files and add or change the HTML and PHP code that defines what appears at the top and bottom of your site. After editing, you save the files and refresh your website in the browser to see the changes. This process is shown step-by-step in the execution table, starting from opening the files, editing, saving, and finally refreshing the page to view the updated header and footer. Remember, changes won't appear until you save and refresh. Also, be careful to back up your files before making edits to avoid losing important code. This method lets you personalize your site's look by controlling the header and footer content directly.

Practice

(1/5)
1. What is the main purpose of using get_header() and get_footer() functions in a WordPress theme?
easy
A. To delete the header and footer sections from a page
B. To add custom CSS styles to the header and footer
C. To register new header and footer menus
D. To include the header and footer template files in a theme's page

Solution

  1. Step 1: Understand the role of get_header() and get_footer()

    These functions load the header.php and footer.php template files into the current page template.
  2. Step 2: Identify their purpose in theme structure

    They help keep the header and footer code separate and reusable across pages.
  3. Final Answer:

    To include the header and footer template files in a theme's page -> Option D
  4. Quick Check:

    Include header/footer = A [OK]
Hint: Remember: get_header() loads header.php, get_footer() loads footer.php [OK]
Common Mistakes:
  • Thinking these functions add CSS styles
  • Confusing with menu registration functions
  • Assuming they remove sections instead of adding
2. Which of the following is the correct way to include a custom header file named header-special.php in a WordPress theme template?
easy
A. include('header-special.php');
B. get_header('special');
C. get_template_part('header-special');
D. load_header('special');

Solution

  1. Step 1: Recall how to load custom header files

    WordPress uses get_header('name') to load header-name.php.
  2. Step 2: Match the function to the file name

    For header-special.php, call get_header('special').
  3. Final Answer:

    get_header('special'); -> Option B
  4. Quick Check:

    Custom header call = B [OK]
Hint: Use get_header('name') to load header-name.php files [OK]
Common Mistakes:
  • Using include() instead of get_header()
  • Confusing get_template_part() with get_header()
  • Using non-existent functions like load_header()
3. Consider this WordPress theme template snippet:
<?php get_header(); ?>
<main>Content here</main>
<?php get_footer(); ?>

What will be the output on the webpage if header.php contains a <header> with "Welcome" text and footer.php contains a <footer> with "Goodbye" text?
medium
A. The page will show an error because get_header() and get_footer() need parameters
B. Only the main content will show, header and footer are ignored
C. The page will show a header with "Welcome", main content, and a footer with "Goodbye"
D. The page will show "Welcome" and "Goodbye" but no main content

Solution

  1. Step 1: Understand what get_header() and get_footer() do

    They insert the contents of header.php and footer.php respectively into the page.
  2. Step 2: Combine the template parts

    The page will display the header content "Welcome", then the main content, then the footer content "Goodbye".
  3. Final Answer:

    The page will show a header with "Welcome", main content, and a footer with "Goodbye" -> Option C
  4. Quick Check:

    Header + main + footer = D [OK]
Hint: get_header() and get_footer() add their files' content around main [OK]
Common Mistakes:
  • Thinking main content is replaced or ignored
  • Assuming parameters are required for these functions
  • Expecting an error without parameters
4. You added get_footer('custom'); in your theme template, but the footer does not appear and the page shows an error. What is the most likely cause?
medium
A. The file footer-custom.php does not exist in the theme folder
B. You must use get_footer() without parameters always
C. The function get_footer() cannot load custom footers
D. You need to register the custom footer in functions.php first

Solution

  1. Step 1: Understand how get_footer('name') works

    It tries to load footer-name.php from the theme folder.
  2. Step 2: Identify the cause of error

    If footer-custom.php is missing, WordPress cannot find the file and throws an error.
  3. Final Answer:

    The file footer-custom.php does not exist in the theme folder -> Option A
  4. Quick Check:

    Missing footer-custom.php = A [OK]
Hint: Check if footer-custom.php file exists before calling get_footer('custom') [OK]
Common Mistakes:
  • Thinking parameters are not allowed in get_footer()
  • Assuming registration is needed for custom footers
  • Ignoring missing file errors
5. You want to create a WordPress theme where the header shows a different logo on the homepage and another logo on all other pages. Which is the best way to customize the header for this?
hard
A. Create two header files: header-home.php and header.php, then use get_header() or get_header('home') conditionally
B. Add both logos in header.php and use CSS to hide/show based on page
C. Use JavaScript to swap logos after the page loads
D. Create a footer file with the logos and include it instead of header

Solution

  1. Step 1: Understand conditional header loading

    WordPress allows loading different header files using get_header('name').
  2. Step 2: Apply conditional logic in template

    Use PHP to check if it is the homepage, then call get_header('home'), else get_header().
  3. Step 3: Organize header files

    Create header-home.php with the homepage logo and header.php with the default logo.
  4. Final Answer:

    Create two header files: header-home.php and header.php, then use get_header() or get_header('home') conditionally -> Option A
  5. Quick Check:

    Conditional header files = C [OK]
Hint: Use get_header('home') for homepage, get_header() for others [OK]
Common Mistakes:
  • Trying to swap logos only with CSS or JavaScript
  • Putting logos in footer instead of header
  • Not using conditional PHP logic for headers