Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function load_tax_parent_template() {
- global $wp_query;
- if (!$wp_query->is_tax)
- return true; // saves a bit of nesting
- // get current category object
- $tax = $wp_query->get_queried_object();
- // trace back the parent hierarchy and locate a template
- while ($tax && !is_wp_error($tax)) {
- $template = STYLESHEETPATH . "/taxonomy-{$tax->slug}.php";
- if (file_exists($template)) {
- load_template($template);
- exit;
- }
- $tax = $tax->parent ? get_term($tax->parent, $tax->taxonomy) : false;
- }
- }
- add_action('template_redirect', 'load_tax_parent_template');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement