WordPress Theme Development 3 - Header

Normally, header.php will start with html doctype declaration, and xhtml namespace. By default, WordPress theme is using XHTML 1.0 Transitional. WordPress function, language_attributes();, will display the language attributes for the html tag. If you want your site supporting XFN (XHTML Friends Network), you can add profile="https://gmpg.org/xfn/11" for the header tag.

Inside header tag, you will have title, of course, content type and description meta tags, links to style sheet, blog RSS feed, comments RSS feeds and pingback. Action hook template tag, wp_head();, should be added too in order to support other WordPress plugin that you decided to install. Other WordPress plugin might add JavaScript in your header tag by calling wp_head();.

Here come to body tag, you might want to display title and desciption on every page in your web site. The header.php is the right place to put all this information. Following is the example header.php code that you can reference.

If you see the example above, there is a condition in meta tag for description. It is showing different description on single post compare to the rest. In single post, it will describe the post title instead of the site description.

By default, WordPress has build-in feeds for blog web site. I choose RSS 2.0 feed. There are others you can choose from, but this is the common one.

Related Posts

References

Comments

Comments powered by Disqus