1. Home
  2. Docs
  3. WordPress Developer
  4. WordPress Theme Development
  5. Template Files List

Template Files List

index.php

The main template file. It is required in all themes.

<?php

   get_header();

   if ( have_posts() ) : while ( have_posts() ) : the_post();

       the_content();

   endwhile;

   else :

       _e( ‘Sorry, no posts matched your criteria.’, ‘textdomain’ );

   endif;

   get_sidebar();

   get_footer();

?>

 

The code of index file calls the footer, header and sidebar template file. It is the web browser call when requesting your site.

Index file defines the FrontPage of your site. It includes DIV classes “entry” and “post,” and DIV tags “container.”

style.css

The main stylesheet. It is required in all themes and contains the information header for your theme.

style.css file needs to be located in the root directory of your theme, not a subdirectory.

The stylesheet must provide details about the Theme in the form of comments.

stylesheet starts with the following:

/*
Theme Name: WPSeeds
Theme URI: https://wpseeds.com
Author: WPSeeds
Author URI: https://wpseeds.org/
Description:WPSeeds guide on WordPress Ttheme development.
Version: 1.0
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Text Domain: wpseeds
Tags: theme-options, comments
*/

  • Theme Name (*): Name of the theme.
  • Theme URI: The URL of a public web page where users can find more information about the theme.
  • Author (*): The name of the individual or organization who developed the theme. Using the Theme Author’s wordpress.org username is recommended.
  • Author URI: The URL of the authoring individual or organization.
  • Description (*): A short description of the theme.
  • Version (*): The version, written in X.X or X.X.X format.
  • License (*): The license of the theme.
  • License URI (*): The URL of the theme license.
  • Text Domain (*): The string used for textdomain for translation.
  • Tags: Words or phrases that allow users to find the theme using the tag filter.
  • Domain Path: Used so that WordPress knows where to find the translation when the theme is disabled. Defaults to /languages.

(*) are required for a theme in the WordPress Theme Repository

After Above comment section you can add css in style.css like

body{
 margin: 0;
 font-family: Arial, Helvetica, Georgia, Sans-serif;
 font-size: 12px;
 text-align: center;
 vertical-align: top;
 background: #ffffff;
 color: #000000;
}

a:link, a:visited{
 text-decoration: underline;
 color: #000000;
}

a:hover{
 text-decoration: none;
}

#wrapper{
 margin: 0 auto 0 auto;
 width: 750px;
 text-align: left;
}

#header{
 float: left;
 width: 750px;
}

#container{
 float: left;
 width: 500px;
}

Stylesheet Guidelines

  • Follow CSS coding standards when authoring your CSS.
  • Use valid CSS when possible.
  • Minimize CSS hacks. The obvious exception is browsers-specific support, usually versions of IE. If possible, separate CSS hacks into separate sections or separate files.
  • All possible HTML elements should be styled by your theme
  • Adding print-friendly styles is highly recommended.
  • Always try to create responsive theme using CSS.

rtl.css

The rtl stylesheet. This will be included automatically if the website’s text direction is right-to-left. This can be generated using the RTLer plugin.

comments.php

The comments template.

front-page.php

The front page template is always used as the site front page if it exists, regardless of what settings on Admin > Settings > Reading.

home.php

The home page template is the front page by default. If you do not set WordPress to use a static front page, this template is used to show latest posts.

header.php

The header template file usually contains your site’s document type, meta information, links to stylesheets and scripts, and other data.

singular.php

The singular template is used for posts when single.php is not found, or for pages when page.php are not found. If singular.php is not found, index.php is used.

single.php

The single post template is used when a visitor requests a single post.

single-{post-type}.php

The single post template used when a visitor requests a single post from a custom post type. For example, single-book.php would be used for displaying single posts from a custom post type named book. The index.php is used if a specific query template for the custom post type is not present.

archive-{post-type}.php

The archive post type template is used when visitors request a custom post type archive. For example, archive-books.php would be used for displaying an archive of posts from the custom post type named books. The archive.php template file is used if the archive-{post-type}.php is not present.

page.php

The page template is used when visitors request individual pages, which are a built-in template.

page-{slug}.php

The page slug template is used when visitors request a specific page, for example one with the “about” slug (page-about.php).

category.php

The category template is used when visitors request posts by category.

tag.php

The tag template is used when visitors request posts by tag.

taxonomy.php

The taxonomy term template is used when a visitor requests a term in a custom taxonomy.

author.php

The author page template is used whenever a visitor loads an author page.

date.php

The date/time template is used when posts are requested by date or time. For example, the pages generated with these slugs:

http://example.com/blog/2014/

http://example.com/blog/2014/05/

http://example.com/blog/2014/05/26/

archive.php

The archive template is used when visitors request posts by category, author, or date. Note: this template will be overridden if more specific templates are present like category.php, author.php, and date.php.

search.php

The search results template is used to display a visitor’s search results.

attachment.php

The attachment template is used when viewing a single attachment like an image, pdf, or other media file.

image.php

The image attachment template is a more specific version of attachment.php and is used when viewing a single image attachment. If not present, WordPress will use attachment.php instead.

404.php

The 404 template is used when WordPress cannot find a post, page, or other content that matches the visitor’s request.

Was this article helpful to you? Yes No

How can we help?