Book Image

WordPress 2.8 Themes Cookbook

By : Nick Ohrn, Lee Jordan
Book Image

WordPress 2.8 Themes Cookbook

By: Nick Ohrn, Lee Jordan

Overview of this book

Themes are among the most powerful features that can be used to customize a web site and give it a professional look, especially in WordPress. Using custom themes you can brand your site for a particular corporate image, ensure standards compliance, and create easily navigable layouts. But most WordPress users still continue to use default themes as developing and deploying themes that are flexible and easily maintainable is not always straightforward and lot of issues pop up during the process.This easy-to-use step-by-step guide will help you create powerful themes for your WordPress web site, and solve your theme development problems in a quick and effective way. It enables you to take full control over your site's design and branding and make it look smarter.WordPress is distributed with two ready-to-use themes. You can use these themes to give a common look to your website, or use the techniques described in this book to create custom themes. This book includes over 100 useful recipes to help you get started and create advanced themes. It starts with the basics of WordPress themes and creating a theme from scratch. Then, it covers how to enhance your template and add effects to get a rich look. You will learn how to manage pages, categories, and tags for your blogs, and how to make your posts look unique. You will also learn about the comment system and sidebars that will help you give a new feel to your blog and web site.This book will help you through the most common problems encountered when developing a WordPress theme. You will get tips to enhance your design skill and eventually enhance your blog's design.
Table of Contents (17 chapters)
WordPress 2.8 Themes Cookbook
Credits
About the Authors
About the Reviewers
Preface

Installing and activating a theme


Once you find or create a theme that is right for you, there is a need to install and activate it so that it can start providing the output for your WordPress install. Installation is easy once you know where WordPress expects theme files to be located, and activation is done through the administration panel with a few clicks. In this recipe, you'll learn exactly how to do both.

Getting ready

Download or create a theme that you wish to install. The theme's files should be contained in a single directory, exactly like the default WordPress themes are packaged.

How to do it...

First, you need to get your theme into the proper location in your WordPress install. Unless you've configured your installation in an unusual way, the correct directory to install your theme is wp-content/themes/. If you're working with a fresh install of WordPress, the directory should contain two subdirectories: default and classic. This is shown in the following screenshot:

Once you get to the correct place, you need to create a new subdirectory for your theme. Here we create a directory called wordpress-themes-cookbook that will hold all of the files for the new theme:

After you've created the directory, place all of your theme's files into the new directory. At this point, if your theme has been constructed properly and contains the necessary files, you can activate the theme for use on your site. Open up your WordPress administrative area and click on the Appearance menu item. You'll see the Manage Themes page, as shown in the screenshot below:

If you need to preview your theme before activating it, click on the Preview link under the theme that you're interested in. After confirming that the view is correct, click on the Activate link in the upper-right corner of the preview box, as shown in the next screenshot:

If you don't wish to preview your new theme, you can click on the Activate link directly. After activation, the page will refresh and you'll be greeted with a message regarding the switch:

How it works...

When you activate a new theme, WordPress stores two values in the database, indicating which theme is active, and what template files should be used. Whenever a page is viewed on the website, WordPress looks up the active theme and uses the correct template files to display the appropriate output.

The two values are located in the WordPress options table for your install and have keys of stylesheet and template. In most circumstances, these two values will be the same. However, if you are using a child theme, the template option will be the name of the folder in which the parent theme is located.