Starting with the Basics

A WordPress theme is a collection of WordPress templates made up of WordPress template tags. When we refer to a WordPress theme, we are talking about the group of templates that makes up the theme. When we talk about a WordPress template, we are referring to only one of the template files that contain WordPress template tags. WordPress template tags make all the templates work together as a theme (more about this topic later in the chapter). These files include

  • The theme's stylesheet: (style.css) The stylesheet provides the theme's name, as well as the CSS rules that apply to the theme. (Later in this chapter we go into detail about how stylesheets work.)
  • The main index template: (index.php) The index file is the first file that will be loaded when a visitor comes to your site. It contains the HTML as well as any PHP code needed on your home page.
  • An optional functions file: (functions.php) This optional file is a place where you can add additional functionality to your site via PHP functions.

Template and functions files end with the .php extension. PHP is the scripting language used in WordPress, which your Web server recognizes and interprets as such (Book II, Chapter 3 covers additional details on the PHP language that you will find helpful). These files contain more than just scripts, though. The PHP files also contain HTML, which is the basic markup language of Web pages.

Within this set of PHP files is all the information your browser and Web server need to make your Web site. Everything from the color of the background to the layout of the content is contained in this set of files.

image The difference between a template and a theme can cause confusion. Templates are individual files. Each template file provides the structure in which your content will display. A theme is a set of templates. The theme uses the templates to make the whole site.

Understanding where the WordPress theme files are located on your web server gives you the ability to find and edit them, as needed. You can view and edit WordPress theme files, using two different methods, by following these steps:

  1. Connect to your Web server via FTP, and have a look at the existing WordPress themes on your server.

    The correct location is /wp-content/themes/. When you open this folder, you find the /twentyten theme folder.

    image If a theme is uploaded to any folder other than /wp-content/themes, it won't work.

  2. Open the folder for the Twenty Ten theme ( /wp-content/themes/twentyten ), and look at the template files inside.

    When you open the Twenty Ten theme folder (see Figure 3-1), you see several files. At minimum, you find these five templates in the default theme:

    • Stylesheet (style.css)
    • Header template (header.php)
    • Main Index (index.php)
    • Sidebar template (sidebar.php)
    • Footer template (footer.php)

    These files are the main WordPress template files, and we discuss them in more detail in this chapter. There are several template files, however, and you should try to explore all of them if you can. Take a peek inside and see the different template functions they contain. These filenames are the same in every WordPress theme.

  3. Log in to your WordPress Dashboard in your Web browser window and click the Editor link on the Appearance menu to look at the template files within a theme.

    This page lists the various templates available within the active theme. (Figure 3-2 shows the templates in the default Twenty Ten theme.) A text box on the left side of the screen displays the contents of each template, and this box is also where you can edit the template file(s). To view and edit a template file, click the template name in the list on the right side of the page.

Figure 3-1: WordPress themes in the /wp-content/themes folder on your Web server.

image

Figure 3-2: A list of templates available in the default Twenty Ten WordPress theme.

image

The Edit Themes page also shows the template tags within the template file. These tags make all the magic happen in your blog; they connect all the templates to form a theme. The next section of this chapter discusses these template tags in detail, showing you what they mean and how they function.

image Below the text box on the Edit Themes page is a drop-down menu labeled Documentation. Click the arrow on the right side of the menu, and a list drops down that contains all the template tags used in the template you are currently viewing. This list is helpful when you edit templates, and it gives you some insight into some of the different template tags used to create functions and features within your WordPress theme.

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

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