Anatomy of a WordPress Theme

November 10, 2004
by Ryan

WordPress themes live in directories residing in wp-content/themes/. A theme named “Test”, for example, might live in wp-content/themes/Test. This theme directory will hold all of the theme’s stylesheets, templates, and images. A WordPress theme must have a stylesheet called style.css. If the theme inherits its templates from another theme, then the theme directory would contain only the stylesheet and possibly some images.

The interesting case is where the theme provides its own templates. In this case, the theme directory must contain an index.php file. This is the master template for the theme, and it must exist. Other templates you most likely will want to include with your theme are comments.php and comments-popup.php. These provide the comment and popup comment templates for your theme. If you do not provide these, the default wp-comments.php and wp-comments-popup.php will be used. These default templates may not match your theme very well, so you probably will want to provide your own.

Those are the basic files needed to make a theme. Place style.css, index.php, comments.php, and comments-popup.php in their own directory beneath wp-content/themes/, and you have a theme. But wait, there’s more. WordPress can load different templates for different query types. The various query types are briefly described here. Basically, if your theme provides a template called category.php and a category is currently being queried, category.php will be loaded instead of index.php. If category.php is not present, index.php is used as usual.

Here is the list of theme files recognized by WordPress. Of course, your theme can contain any templates, stylesheets, images, or other files you wish to include. Just keep in mind that the following have special meaning to WordPress.

  • style.css – The main stylesheet. This must be included with your theme.
  • index.php – The main template. If your theme provides its own templates, index.php must be present.
  • comments.php – The comments template. If not present, wp-comments.php is used.
  • comments-popup.php – The popup comments template. If not present, wp-comments-popup.php is used.
  • single.php – The single post template. Used when a single post is queried. For this and all other query templates, index.php is used if the query template is not present.
  • page.php – The page template. Used when a page is queried.
  • category.php – The category template. Used when a category is queried.
  • author.php – The author template. Used when an author is queried.
  • date.php – The date/time template. Used when a date or time is queried. Year, month, day, hour, minute, second.
  • archive.php – The archive template. Used when a category, author, or date is queried. Note that this template will be overridden by category.php, author.php, and date.php for their respective query types.
  • search.php – The search template. Used when a search is performed.
  • 404.php – The 404 Not Found template. Used when WordPress cannot find a post that matches the query.
67 Responses

Trackbacks & Pingbacks

  1. [bronski.net]
  2. [bronski.net]
  3. Time Is Tight » Anatomy of a WordPress Theme
  4. Bicherele » Anatomy of a WordPress Theme
  5. monkinetic
  6. The Indiana Jones School of Management
  7. skebrown » Anatomy of a WordPress Theme System
  8. Photo Matt » WordPress Themes
  9. scriptygoddess
  10. LostFocus » boren.nu - Blog Archive - Anatomy of a WordPress Theme
  11. Anatomy of a WordPress Theme (A Proletarium Blog)
  12. The weBlog of John » Anatomy of a WordPress Theme
  13. Timing Interval
  14. Timing Interval » Onward to WP 1.3!
  15. Proletarium como tema (skin) | A Proletarium Blog
  16. Frish.nl - As frish as it gets - Rogier Strobbe
  17. [MoK] leonieke.net
  18. alebì.net
  19. geek ramblings
  20. CoffeeSwirls » Swirly Digest
  21. Jenna Pfister » Blog Archive » Now About This Default Style
  22. my links » Anatomy of a WordPress Theme
  23. Jenna Pfister » Blog Archive » Now About This Default Style
  24. The Indiana Jones School of Management » Anatomy of a WordPress 1.5 Theme
  25. WordPress 1.5 Themes » Blog Archive » Resources for Theme Designers
  26. metaforest.net » Anatomy of a WordPress Theme
  27. Desde la distancia » Blog Archive » Wordpress
  28. RJCP » Blog Archive » Wordpress
  29. :: Qbic ::
  30. WordPress Reference Centre » Theme Anatomy
  31. Falo :: Visuelle Anatomie eines WP1.5 Themes
  32. Marius Deac » Blog Archive » wordpress theme
  33. Burning River Studio » Blog Archive » Wordpress Helpfulness
  34. » Theme Creation
  35. 冰古Blog » Blog Archive » 有关wordpress theme的Tips 和 hack
  36. Taking Your Camera on the Road » Common WordPress Support Questions
  37. Chetan’s monologue » Skinning WordPress 1.3
  38. De Culturis Mundi
  39. Visual Anatomy of a WP 1.5 Theme at WordPr.ectio.us
  40. Lorelle on WordPress » Designing a WordPress Theme From Scratch
  41. panjet’s blog » wordpress、php 及 xmlrpc
  42. Shadows » Blog Archive » Theme anatomy
  43. Playing with WordPress
  44. Top 10 WordPress Theme Resources » Nathan Waters: Budding Young Entrepreneur
  45. Blue Mint
  46. Blue Mint » Anatomy of a WordPress Theme
  47. Grant Palin » Blog Archive » Useful WordPress Resources
  48. WordPress 2.0 » Blog Archive » Using Themes
  49. 오픈초이닷컴 » 워드프레스(WordPress) 테마리스트 사이트 모음
  50. ink-N-play » Test 2
  51. Sam Devol :: WordPress Tools and Resources
  52. blogikirja.net » Using Themes
  53. My.diary.in.th » โครงสร้าง Theme ของ Wordpress
  54. The Redesign Cometh (8 Ways to Sunday)
  55. Port MT Default Style to Wordpress Themes? - Laughing Meme
  56. Personal Babblishing
  57. Créez votre thème Wordpress de A à Z !
  58. Everything You Need to Run a WordPress Blog << Vandelay Website Design
  59. Malaysia Contest - Online Contest | Malaysia Contest Forum | Local Contest | International Contest
  60. 09/08/07 Reperage AIA & BC at Artistik Intelligence Agency
  61. Dress Your Blog for Success
  62. 10 links per creare il tuo tema WordPress | Napolux.com
  63. WordPress Tools and Resources » Sam Devol
  64. WordPress Theme Building Resources | J David Macor.com
  65. uowz.com - free for freedom » Blog Archive » Dress Your Blog for Success
  66. Everything You Need to Run a WordPress Blog
  67. WordPress Themes - create your own Wordpress Theme | Independent Digital

Comments are closed for this entry.