<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Jaymin Patel &#187; inherited themes</title>
	<atom:link href="http://www.jayminkapish.com/tag/inherited-themes/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.jayminkapish.com</link>
	<description>Wordpress Developer, New York</description>
	<lastBuildDate>Wed, 09 Nov 2011 15:33:24 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.4-alpha-19719</generator>
		<item>
		<title>Parent Child Theme &#8211; Easiest Way!</title>
		<link>http://www.jayminkapish.com/2009/08/07/parent-child-theme-easiest-way/</link>
		<comments>http://www.jayminkapish.com/2009/08/07/parent-child-theme-easiest-way/#comments</comments>
		<pubDate>Sat, 08 Aug 2009 01:46:10 +0000</pubDate>
		<dc:creator>Jaymin Patel</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[inherited themes]]></category>
		<category><![CDATA[parent child themes]]></category>
		<category><![CDATA[Wordpress MU 2.6.5]]></category>
		<category><![CDATA[wordpress parent child theme]]></category>

		<guid isPermaLink="false">http://blog.kapish.co.in/?p=114</guid>
		<description><![CDATA[This solution will work for you if you want your child theme have fewer templates and if any template is missing, it should not break your blog but should go to parent theme and load it.]]></description>
			<content:encoded><![CDATA[<p>This solution will work for you if you want your child theme have fewer templates and if any template is missing, it should not break your blog but should go to parent theme and load it.</p>
<p>And a few important things to set,<br />
1) parent theme folder name<br />
2) child theme folder name<br />
3) Template set in child theme style.css must match parent theme folder name</p>
<p>Because child theme name and Template set in child theme style.css are stored in options table.<br />
<span id="more-114"></span><br />
So I started looking into wordpress core files</p>
<div class="phpcode"><code> wp-includes/template-loader.php<br />
wp-includes/theme.php<br />
</code></div>
<p>These files load templates from active theme on your blog.</p>
<p><strong>What parent theme must have</strong><br />
Your parent theme must have all template files necessary for any typical wordpress theme and parent <strong>style.css</strong> must have these lines</p>
<div class="phpcode"><code>/*<br />
Theme Name: Parent Theme<br />
Theme URI: Your Blog URL<br />
Description: My Parent Theme<br />
Version: 0.1<br />
Author: Your Name<br />
Author URI: mailto:your_email_goes_here<br />
*/<br />
</code></div>
<p><strong>What child theme must have</strong></p>
<p><strong>style.css</strong> must have these lines where <strong>my_child_theme</strong> must be the name of child theme folder and <strong>my_parent_theme</strong> must be the name of parent theme folder.</p>
<div class="phpcode"><code>/*<br />
Theme Name: my_child_theme<br />
Theme URI: Your Blog URL<br />
Description: My Child Theme<br />
Version: 0.1<br />
Author: Your Name<br />
Author URI: mailto:your_email_goes_here<br />
Template: my_parent_theme<br />
*/<br />
</code></div>
<p>and <strong>screenshot.png</strong> and <strong>functions.php</strong></p>
<p>functions.php should add_filter to &#8216;home_template&#8217;</p>
<div class="phpcode"><code>add_filter('home_template', 'load_child_home_template');<br />
</code></div>
<p>I am going to take home/index template as an example here. Lets say child theme is having these files. What does this mean? This means you want index.php/home.php loaded from child theme and everything else should come from parent theme.<br />
1) style.css<br />
2) screenshot.png<br />
3) index.php or home.php<br />
4) functions.php</p>
<p>wp-includes/theme.php has</p>
<div class="phpcode"><code>function get_home_template() {<br />
$template = '';<br />
if ( file_exists(TEMPLATEPATH . "/home.php") )<br />
$template = TEMPLATEPATH . "/home.php";<br />
elseif ( file_exists(TEMPLATEPATH . "/index.php") )<br />
$template = TEMPLATEPATH . "/index.php";<br />
return apply_filters('home_template', $template);<br />
}</p>
<p></code></div>
<p>WordPress applies filters at the end and we are going to take advantage of it.</p>
<p>child theme functions.php must have this function as well</p>
<div class="phpcode"><code>function load_child_home_template($template) {<br />
if(empty($template)) {<br />
$template = 'index.php'; /* if you have home.php, replace index.php with home.php */<br />
}<br />
return check_child_template($template);<br />
}<br />
function check_child_template($template) {<br />
$template_file_name = basename($template);<br />
$template_option = get_option('template'); /* has 'my_parent_theme' */<br />
$current_theme_option = get_option('current_theme'); /* has 'my_child_theme' */<br />
$theme_root = get_theme_root();<br />
$child_template_root = $theme_root . '/' . $current_theme_option;<br />
$child_template = $child_template_root . '/' . $template_file_name;<br />
$parent_template_root = $theme_root . '/' . $template_option;<br />
$parent_template = $parent_template_root . '/' . $template_file_name;<br />
if(file_exists($child_template)) {<br />
return $child_template; /* if child theme has index.php/home.php, load it */<br />
}<br />
else if(file_exists($parent_template)) { /* if child is missing index.php/home.php, load index.php/home.php from parent */<br />
return $parent_template;<br />
}<br />
return $template;<br />
}</p>
<p></code></div>
<p>You may want to put some html comments in parent theme index.php/home.php and child theme index.php/home.php to debug which theme is serving home page by looking into source code.</p>
<p>More on themes on <a href="http://codex.wordpress.org/Using_Themes#Creating_Themes">WordPress Codex</a></p>
<h3>Related Posts</h3><ul class="related_post"><li><a href="http://www.jayminkapish.com/2010/09/30/wordpress-instant-search-plugin/" title="Wordpress Instant Search Plugin">Wordpress Instant Search Plugin (1)</a></li><li><a href="http://www.jayminkapish.com/2009/12/08/secure-your-wordpress-installation/" title="Secure Your Wordpress Installation">Secure Your Wordpress Installation (0)</a></li><li><a href="http://www.jayminkapish.com/2009/10/08/wordpress-mu-site-upgrade-bug-your-server-may-not-be-able-to-connect-to-blogs-running-on-it/" title="Wordpress MU Site Upgrade Bug: Your server may not be able to connect to blogs running on it">Wordpress MU Site Upgrade Bug: Your server may not be able to connect to blogs running on it (3)</a></li><li><a href="http://www.jayminkapish.com/2009/03/17/json-and-wordpress/" title="JSON and Wordpress">JSON and Wordpress (9)</a></li><li><a href="http://www.jayminkapish.com/2008/06/13/comments-pagination-wordpress/" title="Comments Pagination &#8211; Wordpress &#8211; Bug Fixed!">Comments Pagination &#8211; Wordpress &#8211; Bug Fixed! (22)</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.jayminkapish.com/2009/08/07/parent-child-theme-easiest-way/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Served from: www.jayminkapish.com @ 2012-02-06 04:32:07 by W3 Total Cache -->
