#summary Advanced Customization of K2 via Child Themes.
#labels Documentation-Howto
With !WordPress 2.7+, it is now possible to override K2's template files by creating a child theme of K2. This allows you to customize K2 without changing the core files.
== Creating a Child Theme ==
- Create a new folder in the !WordPress themes folder (wp-content/themes/) to contain your child theme files. (_Do not create the folder inside of K2 or the K2 Styles folder: k2/styles/._)
For example: wp-content/themes/*k2-custom*/
-
Create a *style.css* file with the following content:
{{{
/*
Theme Name: your child theme name
Theme URI: the-theme's-homepage
Description: a-brief-description
Author: your-name
Author URI: your-URI
Template: K2
*/
}}}
Note: Make absolutely sure whatever you have in Template: matches the folder name that K2 resides in. This is case-sensitive. For example: if K2 resides in the path wp-content/themes/kaytwo-1.0/, you would use:
{{{
Template: kaytwo-1.0
}}}
-
Copy K2's *screenshot.jpg* into your child theme folder.
Now our example child theme contains:
* k2-custom/
* style.css
* screenshot.jpg
-
Activate your child theme via Appearance > Themes panel.
== Customizing K2 ==
Refer to [K2CSSandCustomCSS] on customizing css.
Now that you have a blank child theme, you can now start customizing K2. Just make a copy of the template file that you would like to modify into your child theme folder.
For example, to customize the Single Post template (single.php), make a copy of single.php into your child theme folder and edit away. Be sure to leave K2's single.php intact.
You can also include a *functions.php* file with your child theme. Refer to the [http://codex.wordpress.org/Plugin_API WordPress Plugin API] for more info.
_Note: Please do not modify anything inside the k2/app/ folder._
=== K2 Blocks ===
Content from certain parts of K2 are now stored in the *k2/blocks/* folder.
|| k2-header.php || contains all content in *div#header*, including the header menu ||
|| k2-footer.php || contains all content in *div#footer* ||
|| k2-loop.php || contains the post loop ||
*k2-loop.php* is a special case. You can target your customizations to a specific query by making a copy k2-loop.php and naming it:
* k2-loop-home.php - blog home
* k2-loop-search.php - search results
* k2-loop-archive.php - all archives including:
* k2-loop-author.php - author archives
* k2-loop-archive-date.php - date based archives including:
* k2-loop-archive-day.php - daily archives
* k2-loop-archive-month.php - monthly archives
* k2-loop-archive-year.php - yearly archives
* k2-loop-category.php - all category archives
* k2-loop-category-*n*.php - for a specific category (n is the category id number, example: k2-loop-category-5.php)
* k2-loop-tag.php - all tag archives
* k2-loop-tag-*s*.php - for a specific tag (s is the tag, example: k2-loop-tag-photos.php)
=== Hooks ===
Below is a list of hooks provided by K2 and where they appear in the generated HTML source. You can insert content via your child theme's *functions.php* file or by using the [http://wordpress.org/extend/plugins/k2-hook-up/ K2 Hook Up] plugin.
{{{
}}}