Building your WordPress theme template files

OK! We're ready to start. Open your HTML editor program and set it up to display your FTP or local working directory in a files panel, giving you access to your WordPress installation files. Also, have a couple of browser windows open with your WordPress home page loaded into one, as well as the WordPress Administration panel available in another.

Starting with a blank slate

The approach we'll use here includes the following steps (we'll go over each step in detail):

  1. Create a new, empty theme directory (but don't delete the default theme—leave that safely where it is).
  2. Upload your mockup's image directory as well as your index.html and style.css mockup files to the directory.
  3. Add some commented-out code to your stylesheet for WordPress to work with.
  4. Rename your index.html file to index.php.
  5. Add the WordPress template tag PHP code, specifically the blog_info tag and the loop, to your design so that your stylesheet styles and some WordPress content shows up.
  6. Once your theme's WordPress content is loading in and your HTML and CSS still work and look correctly, then you can pull it apart into your theme's corresponding template files, such as header.php, footer.php, sidebar.php and so on.
  7. Once your theme design is separated out into logical template files, you can begin finalizing any special display requirements your theme has, such as a different home page layout, internal page layouts, and extra features using template tags and API hooks, so your theme works with plugins. That will be a job for a later chapter.

The other advantage to this approach is that if any part of your theme starts to break, you can narrow it down to WordPress PHP code that wasn't copied into its own template file correctly. You'll always have your backup files to return to if anything goes wrong.

Creating a new theme directory

To get started, we'll create a copy of the existing default theme. We'll be using a development installation of WordPress 3.4.2 on a remote server, and using TextWrangler with its inbuilt FTP capability to edit the code. If you prefer, you can work on a local installation of WordPress.

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

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