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.
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.
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:
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.