Basics of a WordPress theme

According to the WordPress codex a WordPress theme is:

A collection of files that work together to produce a graphical interface with an underlying unifying design for a weblog.

Themes are comprised of a collection of template files and web collateral such as images, CSS stylesheets, and JavaScript.

The next diagram illustrates how the WordPress theme works with the WordPress system: core installation, theme files, plugin files, and MySQL database, to serve up a complete HTML page to the browser:

Basics of a WordPress theme

We'll go over the specifics and code examples of each part of a WordPress theme in detail in Chapter 3, Coding it Up, but here are the basics to get you started:

The template hierarchy

The most important part of a WordPress theme to start realizing now is the template hierarchy . A WordPress theme is comprised of many file types including template pages. Template pages have a structure or hierarchy to them. That means, if one template file is not present, then the WordPress system will call up the next level template file. This allows developers to create themes that are fantastically detailed, which take full advantage of all of the hierarchy's available template files, and yet make the setup unbelievably simple. It's also possible to have a fully functioning WordPress theme that consists of no more than an index.php file and a stylesheet.

Note

You can see the template hierarchy in detail at http://codex.wordpress.org/Template_Hierarchy.

The Loop

Within most template pages in the hierarchy (not necessarily all of them), we'll be adding a piece of code called "the Loop ". The Loop is an essential part of your WordPress theme. It displays your posts in chronological order and lets you define custom display properties with various WordPress template tags wrapped in HTML markup.

Template tags and API hooks

Looking within a template page's "Loop", you'll find some interesting bits of code wrapped in PHP tags. The code isn't pure PHP, most of them are WordPress-specific tags and functions such as template tags, which only work within a WordPress system. Most tags and functions can have various parameters passed through them.

Not all WordPress tags and functions go inside the Loop. If you were to poke around the header.php file included in the default Twenty Ten theme, you'll find several tags that work outside the Loop. Specifically in the header.php template page (as well as the footer.php and sidebar.php template pages), you'll also find several WordPress-specific functions that are part of the Plugin API and Script API .

Again, no need to worry about the specifics of these now. We'll be covering all these terms in detail with examples in Chapter 3, Coding it Up, plus the Appendix will have a complete Quick Reference Cheat Sheet for you to quickly look up all of these specifics.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.149.26.246