Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function cp_template_redirect() {
- global $post;
- // organization single
- if (is_single() && $post->post_type == 'organizations') {
- $tmpl_file_name = 'single-organizations.php';
- if ( $overridden_template = locate_template( 'cp-default/'.$tmpl_file_name ) ) {
- // locate_template() returns path to file
- // if either the child theme or the parent theme have overridden the template
- load_template( $overridden_template );
- } else {
- // If neither the child nor parent theme have overridden the template,
- // we load the template from the 'templates' sub-directory of the directory this file is in
- $base = 'casepress/cp-templates/cp-default';
- $includes = implode( '/', array( WP_PLUGIN_DIR, $base ) );
- include_once $includes.'/hooks.php';
- load_template( $includes.'/'.$tmpl_file_name, true );
- }
- die;
- }
- // cases single
- if (is_single() && $post->post_type == 'cases'){
- $tmpl_file_name = 'single-cases.php';
- if ( $overridden_template = locate_template( 'cp-default/'.$tmpl_file_name ) ) {
- // locate_template() returns path to file
- // if either the child theme or the parent theme have overridden the template
- load_template( $overridden_template );
- } else {
- // If neither the child nor parent theme have overridden the template,
- // we load the template from the 'templates' sub-directory of the directory this file is in
- $base = 'casepress/cp-templates/cp-default';
- $includes = implode( '/', array( WP_PLUGIN_DIR, $base ) );
- include_once $includes.'/hooks.php';
- load_template( $includes.'/'.$tmpl_file_name, true );
- }
- die;
- }
- // cases table
- if ($post->post_type == 'page' && $post->ID == get_option('page_for_cases_list')){
- $tmpl_file_name = 'template-cases.php';
- if ( $overridden_template = locate_template( 'cp-default/'.$tmpl_file_name ) ) {
- // locate_template() returns path to file
- // if either the child theme or the parent theme have overridden the template
- load_template( $overridden_template );
- } else {
- // If neither the child nor parent theme have overridden the template,
- // we load the template from the 'templates' sub-directory of the directory this file is in
- $base = 'casepress/cp-templates/cp-default';
- $includes = implode( '/', array( WP_PLUGIN_DIR, $base ) );
- include_once $includes.'/hooks.php';
- load_template( $includes.'/'.$tmpl_file_name, true );
- }
- die;
- }
- }
- add_action('template_redirect', 'cp_template_redirect', 10);
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement