Custom Theme in WordPress
This article is about developing WordPress Themes. In this article I will discusses the technical aspects of writing code to build your own themes rather than how to activate themes or where to obtain new themes.
WordPress Themes are files that work together to create the design and functionality of a WordPress site. Each Theme may be different, offering many choices for site owners to take advantage of in order to instantly change their website look.
Let me show you a brief demonstration on it.
Theme Style sheet (Style.css):
Stylesheet (Style.css) provides the details about theme in the form of comments. No two themes are allowed to have the same details listed in their comment headers, as this will lead to problems in the theme selection dialog. If you make your own theme by copying an existing one, make sure some changes in ‘Style.css’ such as theme name, author name, URI etc.
Let’s see a snapshot on it.
The comment header lines in ‘Style.css’ are required for WordPress to be able to identify a theme and display it in the Administration Panel ->Appearance-> Themes path as an available theme option along with any other installed themes.
Function File (function.php):
A theme can optionally use a functions file, which resides in the theme subdirectory and is named ‘functions.php’. This file basically acts like a plugins, and if it is present in the theme you are using, it is automatically loaded during WordPress initialization (both for admin pages and external pages).
Function file (function.php) is used for performing following task.
· Enable Theme Features such as Sidebars, Navigation Menus, Post Thumbnails, Post Formats, Custom Headers, Custom Backgrounds and others.
· Define functions used in several template files of your theme.
· Set up an options menu, giving site owners options for colors, styles, and other aspects of your theme.
The default WordPress theme contains a functions.php file that defines many of these features, so you might want to use it as a model. Since functions.php basically functions as a plugins.
Templates are PHP source files used to generate the pages requested by visitors, and are output as HTML. WordPress allows you to define separate templates for the various aspects of your site. It is not essential, however, to have all these different template files for your site to fully function. Templates are chosen and generated based upon the template hierarchy, depending upon what templates are available in a particular theme.
Here is the list of the theme files recognized by WordPress such as Style.css, header.php, footer.php, archieve.php, index.php, page.php, sidebar.php etc.
These files have a special meaning with regard to WordPress because they are used as a replacement for index.php, when available, according to the template hierarchy, and when the corresponding conditional tag returns true.