Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class moulding_templates {
- public static function determine_template(){
- global $post,$wp_query;
- // custom post types
- $post_type_array = array('moulding_profiles','moulding_combination','moulding_collection','idea_gallery');
- foreach ($post_type_array as $post_type_single) {
- global $post;
- if (is_singular($post_type_single)) {
- moulding_templates::loadSingleTemplate($post);
- }
- }
- // custom taxonomies
- $taxonomy_array = array('profile_categories','combination_categories','wood_types');
- foreach ($taxonomy_array as $taxonomy_single) {
- if (is_tax($taxonomy_single)) {
- moulding_templates::loadTaxonomyTemplate($taxonomy_single);
- }
- }
- }
- private static function loadSingleTemplate($post) {
- $template_name = 'moulding-templates/single-'.$post->post_type.'.php';
- $template = locate_template(array($template_name), true);
- if(empty($template)) {
- include(MOULDINGS_BASE_DIR . 'includes/' . $template_name);
- exit();
- }
- }
- private static function loadTaxonomyTemplate($taxonomy) {
- $template_name = 'moulding-templates/taxonomy-'.$taxonomy.'.php';
- $template = locate_template(array($template_name), true);
- if(empty($template)) {
- include(MOULDINGS_BASE_DIR . 'includes/' . $template_name);
- exit();
- }
- }
- }
- add_action('template_include', array('moulding_templates', 'determine_template'));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement