Forum Replies Created
-
AuthorPosts
-
Nadir Keval
KeymasterSimilarly, if the user clicks on a link for a particular category, WordPress will use the category.php template if it exists; if it doesn’t, it looks for archive.php, and if that template is also missing, WordPress will go ahead and use the main index.php template. You can even make special template files for specific categories (see Category Templates for more information).
Nadir Keval
KeymasterWordPress automatically recognizes template files with certain standard names and uses them for certain types of web pages. For example, when a user clicks on the title of a blog post, WordPress knows that they want to view just that article on its own web page. The WordPress template hierarchy will use the single.php template file rather than index.php to generate the page — if your Theme has a single.php file.
Nadir Keval
KeymasterYou can use the index.php template file to generate all of these types of pages or rely on WordPress’ template hierarchy to choose different template files depending on the situation.
The WordPress Template Hierarchy answers the following question:
Nadir Keval
KeymasterThe multi-post view lists multiple posts or post summaries, and applies to category archives, date archives, author archives, and (usually) the “normal” view of your blog’s home page.
Nadir Keval
KeymasterAfter you have created the child theme you must then enable it through the Administration Panels > Appearance > Themes. You should see your child theme as a separate theme and should bear the name you gave it in the style.css under Theme Name. Just creating a child theme will not activate it and make it visible on your website. Note that a child theme’s stylesheet replaces the stylesheet of the parent completely. (
Nadir Keval
KeymasterAuthor. (optional) Author name.
Author URI. (optional) Author webpage.
Template. (required) directory name of parent theme, case-sensitive.
NOTE. You have to switch to a different theme and back to the child theme when you modify this line.Nadir Keval
KeymasterA quick explanation of each line:
Theme Name. (required) Child theme name.
Theme URI. (optional) Child theme webpage.
Description. (optional) What this theme is. E.g.: My first child theme. Hurrah!Nadir Keval
KeymasterHere is an example information header of a child theme’s style.css:
/*
Theme Name: Twenty Twelve Child
Theme URI: http://example.com/
Description: Child theme for the Twenty Twelve theme
Author: Your name here
Author URI: http://example.com/about/
Template: twentytwelve
Version: 0.1.0
*/Nadir Keval
KeymasterAs with any WordPress theme, the information header must be at the top of the file, the only difference being that in a child theme the Template: line is required, so that WordPress knows which theme is the parent of the child theme.
Nadir Keval
KeymasterA child theme resides in its own directory in wp-content/themes. The scheme below shows the location of a child theme along with its parent theme (Twenty Twelve) in a typical WordPress directory structure:
Nadir Keval
KeymasterFor this reason, child themes are the recommended way of making modifications to a theme.
With a basic understanding of PHP, WordPress Templates, and the WordPress Plugin API, you can make the child theme extend virtually every aspect of a parent theme, and again, without actually changing the parent theme files.
Nadir Keval
KeymasterThe child theme contains a “Template: parent-theme-dir” header to distinguish it from standalone themes. With a little understanding of HTML and CSS, you can make that very basic child theme modify the styling and layout of a parent theme to any extent without editing the files of the parent theme itself. That way, when the parent theme is updated, your modifications are preserved.
Nadir Keval
KeymasterMaking a child theme is very simple. Create a directory by using FTP or whatever file management application your host provides. Put a properly formatted style.css file in it, and you have a child theme!
Nadir Keval
KeymasterThe optional functions file (functions.php) as part of the WordPress Theme files.
Let’s look at these individually.Nadir Keval
KeymasterWordPress Themes typically consist of three main types of files, in addition to images and JavaScript files.
The stylesheet called style.css, which controls the presentation (visual design and layout) of the website pages.
WordPress template files which control the way the site pages generate the information from your WordPress database to be displayed on the site. -
AuthorPosts