In creating a child theme for the new Twenty Twelve theme, I’ve come across a couple of small bugs and have decided this is one of the easiest ways to beta test a new default theme: by using it. You should too!
Author: Drew Jaynes
Drew is a former Core Developer for the WordPress open source project, and he works on cool plugins like AffiliateWP, Easy Digital Downloads, and Restrict Content Pro.
Git branch as subdomain
Wouldn’t it be _awesome_ to be able to dynamically map a subdomain to a git branch on a development server? No cloning, just pure awesome. I can dream.
Force sub-categories to use the parent category template
A couple of times in the last several years, I’ve needed sub-categories to inherit their parent’s archive template, but it’s just not something the Template Hierarchy supports. I’ve seen several plugins that tried and failed to do it, so finally I wrote a little filter that in my testing, works any number of levels deep, from sub-sub-categories to sub-sub-sub-categories. Enjoy!
function new_subcategory_hierarchy() { $category = get_queried_object(); $parent_id = $category->category_parent; $templates = array(); if ( $parent_id == 0 ) { // Use default values from get_category_template() $templates[] = "category-{$category->slug}.php"; $templates[] = "category-{$category->term_id}.php"; $templates[] = 'category.php'; } else { // Create replacement $templates array $parent = get_category( $parent_id ); // Current first $templates[] = "category-{$category->slug}.php"; $templates[] = "category-{$category->term_id}.php"; // Parent second $templates[] = "category-{$parent->slug}.php"; $templates[] = "category-{$parent->term_id}.php"; $templates[] = 'category.php'; } return locate_template( $templates ); } add_filter( 'category_template', 'new_subcategory_hierarchy' );