1

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

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?

1 Answer 1

3

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.
3
  • I figured it was something like firing a hook for plugins.
    – leeand00
    Commented Aug 24, 2010 at 23:20
  • 1
    Can you recommend a good theme tutorial for version 3.0.1?
    – leeand00
    Commented Aug 24, 2010 at 23:23
  • 1
    Personally, I'd say the best tutorial is just to look at how twentyten is built, using the Codex as a guide when you need to reference a function. Commented Aug 25, 2010 at 13:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.