Join Joseph Lowery for an in-depth discussion in this video Understanding WordPress structure, part of Dreamweaver CS6 and WordPress 3.8: Core Concepts.
One of the real strengths of WordPress is its flexibility. You can easily switch the look and feel of your site to one completely different, by activating a different theme. New pages can be quickly added for any special purpose. Content can be grouped by custom tags or categories, added on the fly. However, all this flexibility comes at a price. WordPress is a pretty complex application. In this lesson, I'm going to explain just how WordPress works, so you can get a better grasp of what your options are when creating a custom blog.
The first thing that happens is a visitor requests an initial WordPress page, and that's index.php. This starts the whole ball rolling, as viewing any web page would. WordPress then activates its themes. This is one of the first lines of executable code in the index.php file. Next, WordPress checks to see which template files are available. WordPress works with a series of template files that it dynamically assembles together to create the desired page.
Next, the application gathers the settings that are stored in the MySQL database, which includes all the default settings and any ones that have been customized, such as the title of the site. Then it retrieves the specified number of the most recent posts. You can set how many posts you want to show through the WordPress Settings category. Then, it stores all the data from the post, the title, author, content, and so forth, in variables.
Finally, it outputs all this data into a theme page according to the coded layout and CSS styles that are applied. When you customize a theme, this is where most of the work lies. As you can see, there's a lot going on. And it all happens in the blink of an eye. And this is just for the homepage. WordPress is capable of displaying all types of posts, including those for a specific post, archives, posts under a particular category or with a specific tag. One of the key paths to developing custom WordPress blogs is to understand what happens when these and other types of pages are requested.
Remember this step where WordPress checks to see which template files are present? A theme doesn't have to have a specific file for every type of page. WordPress has a template hierarchy built in that determines what to do if a needed file is missing. Let me give you an example. Let's say a site visitor clicks on the author's name, mine in this example, to see all the posts that he or she wrote. First, WordPress looks to see if there's a template that combines the author prefix with the author's so-called nice name, and uses that if there is.
If there's not, it looks for one with the user id. If that's not there, it tries to display the generic author.php template. Should that template be unavailable, it looks for a theme specific archive.php. And if that's not there, it uses the index.php template. The WordPress template hierarchy covers all the different use cases. You can see a complete diagram of the hierarchy at this URL.
Be sure to click on the image in order to see an expanded version of it. The template hierarchy gives web designers a tremendous degree of control. You can basically decide how much you want to fine tune the structure and layout of your WordPress blog on a page by page basis. So, now that you have a better understanding of how WordPress works in general, you're ready to see how themes fit into the picture.
- Setting up WordPress locally
- Establishing your Dreamweaver CS6 site
- Adding and editing posts and pages
- Customizing WordPress themes
- Building responsive layouts
- Extending WordPress editable pages
- Using and styling WordPress plugins
- Integrating Spry functionality
- Publishing your WordPress site with Dreamweaver
- Personalizing and enhancing WordPress