WordPress Theme Development Seemingly Awful Partitioning of Includes?

I just finished a tutorial that told me to create my header.php without closing a tag at the bottom of the included file.

Read More

Now while I realize that in anyone of the parent files which includes header.php it includes the closing tag; this really goes against my better judgement as a front-end developer; because someone who edits the theme later (and it could be me, it could be somebody else) would have to know that this tag needed to be closed in the parent file which includes it. It just feels wrong. It feels like when your editor marks the tag as “an extra closing tag” you want to delete it.

I’m not breaking a standard if I use:

<?php include(TEMPLATEPATH . '/justTheHTMLHeader.php'); ?>
<!-- AND -->
<?php include(TEMPLATEPATH . '/justTheBlogHeader.php');` ?>

instead of get_header()?

It seems to me that this approach would be more modular and not leave any extraneous tags not closed between included files and their parents.

I also noticed that the default WordPress template is setup this way, so I’m obviously wrong and breaking some sort of WordPress theme standard not matter what I think.

What’s the reasoning behind this?

Related posts

Leave a Reply

1 comment

  1. Well, that tutorial is pretty old and out of date. It was written for WordPress 2.0; 10 major releases ago.

    The short answer is: it’s done that way because it’s the best way to do it. It’s the fastest/simplest way to separate content from design and give all the control to you, the theme developer.

    If you don’t want to open a tag in the header without closing it in the header, don’t. I personally always do that (although I usually close it in the footer, not the index.php file). The great thing about WordPress is that it lets you do whatever you want.

    Here are two good reasons to use get_header():

    1. It fires an action hook that plugins may be using, and
    2. It makes your theme more compliant and therefore easier to use as a template for child themes.