articles

Custom Theme in WordPress

Custom Theme in WordPress

Anonymous User6079 14-Nov-2011

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 web site. every Theme may be different, offering many choices for site owners to take advantage of in order to instantly change their website look.

WordPress Themes generally consist of three main types of files, in addition to images and JavaScript files. First one is ‘Style.css’ which handle the presentation of the website pages; second one is function file (function.php) and last one is ‘Template file’ which handle the way of website pages generate the information from your WordPress database to be displayed on the site.

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.

Custom Theme in WordPress

The comment header lines in ‘Style.css’ are required for WordPress to be able to identify the 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 perform 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.
  • It is Enable Theme Features such as Sidebars, Navigation Menus, Post Thumbnails, Post Formats, Custom Headers, Custom Backgrounds and others.
  • It is Define functions used in several template files of your theme.
  • It is 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.

Template File:

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.


Updated 04-Mar-2020
I am a content writter !

Leave Comment

Comments

Liked By