/* SORTING FUNCTION TO ALPHABETIZE SUB CATEGORY TEMPLATES */ function alphabetize_sub_categories($a, $b) { $a = (array) $a; $b = (array) $b; return strcasecmp($a['post_title'], $b['post_title']); } /* ENABLE PRODUCT LIBRARY SUB CATEGORY TEMPLATE */ function product_library_sub_template() { global $posts; if (is_category()) { if (cat_is_ancestor_of('6', get_query_var('cat'))) { usort($posts, 'alphabetize_sub_categories'); load_template(TEMPLATEPATH . '/product-library-sub-template.php'); exit; } } } add_action('template_redirect', 'product_library_sub_template');