• I was taught to put the header stuff into header.php, the footer stuff into footer.php, and so on. But it hit me today that I don’t know why it is advantageous to split things up that way. I’m happy to load the style sheet in header.php, but is there some reason why I should keep my banner div in header.php and not move it into page.php? And similarly with the footer stuff? The advantage of having everything in one place (page.php) would be: eliminate mistakes about closing the wrapper div. If you’ve got one </div> too many, you end up closing the wrapper div prematurely, often without realizing it.

    I’m fine with keeping the sidebar code in sidebar.php. I like the idea of putting the logic of whether to use the sidebar in page.php, and putting the actual sidebar code into sidebar.php.

Viewing 7 replies - 1 through 7 (of 7 total)
  • Headers and footers are used in multiple template files – not just page.php

    Thread Starter number cruncher

    (@number-cruncher)

    Thanks! So if I’ve got a simple situation with no multiple templates, there’s nothing wrong with moving the header and footer stuff to page.php?

    You have no posts, no categories or archives?

    Thread Starter number cruncher

    (@number-cruncher)

    I do — but I don’t think that resulted in multiple templates, did it? The only files I’ve modified are header.php, page.php, footer.php, style.css and functions.php. Everything else I’ve done via the admin panel.

    I do — but I don’t think that resulted in multiple templates, did it?

    Your single posts use the single.php template file. Archive, category & tags pages may use archive.php, category.php and tag.php template files respectively. The results of any searches are displayed using the search.php template file.

    All of these files require header & footer – hence a single header.php file and a single footer.php file that can be included in each and every one of your theme’s template files.

    Thread Starter number cruncher

    (@number-cruncher)

    I see.

    Thank you, Esmi.

    Also it’s a good idea to develop standard habits. A standard approach across all sites means you are less likely to make mistakes. Also this site may be simple (now) but may become more complex, requiring you to rework it.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘advantages of splitting up layout into header, page, footer’ is closed to new replies.