Advertisement
Guest User

Untitled

a guest
Jun 7th, 2013
40
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3.     function cp_template_redirect() {
  4.         global $post;
  5.  
  6.         // organization single
  7.         if (is_single() && $post->post_type == 'organizations') {
  8.             $tmpl_file_name = 'single-organizations.php';
  9.             if ( $overridden_template = locate_template( 'cp-default/'.$tmpl_file_name ) ) {
  10.                 // locate_template() returns path to file
  11.                 // if either the child theme or the parent theme have overridden the template
  12.                 load_template( $overridden_template );
  13.             } else {
  14.                 // If neither the child nor parent theme have overridden the template,
  15.                 // we load the template from the 'templates' sub-directory of the directory this file is in
  16.                 $base = 'casepress/cp-templates/cp-default';
  17.                 $includes = implode( '/', array( WP_PLUGIN_DIR, $base ) );
  18.                 include_once $includes.'/hooks.php';
  19.                 load_template( $includes.'/'.$tmpl_file_name, true );
  20.             }
  21.             die;
  22.         }
  23.        
  24.         // cases single
  25.         if (is_single() && $post->post_type == 'cases'){
  26.             $tmpl_file_name = 'single-cases.php';
  27.             if ( $overridden_template = locate_template( 'cp-default/'.$tmpl_file_name ) ) {
  28.                 // locate_template() returns path to file
  29.                 // if either the child theme or the parent theme have overridden the template
  30.                 load_template( $overridden_template );
  31.             } else {
  32.                 // If neither the child nor parent theme have overridden the template,
  33.                 // we load the template from the 'templates' sub-directory of the directory this file is in
  34.                 $base = 'casepress/cp-templates/cp-default';
  35.                 $includes = implode( '/', array( WP_PLUGIN_DIR, $base ) );
  36.                 include_once $includes.'/hooks.php';
  37.                 load_template( $includes.'/'.$tmpl_file_name, true );
  38.             }
  39.             die;
  40.         }
  41.  
  42.         // cases table
  43.         if ($post->post_type == 'page' && $post->ID == get_option('page_for_cases_list')){
  44.             $tmpl_file_name = 'template-cases.php';
  45.             if ( $overridden_template = locate_template( 'cp-default/'.$tmpl_file_name ) ) {
  46.                 // locate_template() returns path to file
  47.                 // if either the child theme or the parent theme have overridden the template
  48.                 load_template( $overridden_template );
  49.             } else {
  50.                 // If neither the child nor parent theme have overridden the template,
  51.                 // we load the template from the 'templates' sub-directory of the directory this file is in
  52.                 $base = 'casepress/cp-templates/cp-default';
  53.                 $includes = implode( '/', array( WP_PLUGIN_DIR, $base ) );
  54.                 include_once $includes.'/hooks.php';
  55.                 load_template( $includes.'/'.$tmpl_file_name, true );
  56.             }
  57.             die;
  58.         }
  59.     }
  60.     add_action('template_redirect', 'cp_template_redirect', 10);
  61. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement