<?php
/**
 * The main template file chooser
 *
 * Methods for TimberHelper can be found in the /lib sub-directory
 *
 * @package  WordPress
 * @subpackage  Creativedog Timber
 * @since   Timber 0.1
 */

	$params = array();
	$post_type = get_post_type();

	if( $post_type ):
		$template = get_page_template_slug();
		if($template){
			$params['template'] = $template;
		}
	endif;

	if ( is_search() ):
		$post_type = 'page';
		$params['template'] = 'search';
	endif;

	if ( is_tag() || is_category() || is_tax() ):
		$post_type = 'taxonomy';
		$queried_object = get_queried_object();
		$params['template'] = get_queried_object()->taxonomy;
	endif;

	if ( is_author() ):
		$post_type = 'author';
	endif;

	if( is_404() ):
		$post_type = 'page';
		$params['template'] = '404';
	endif;

	CDController::init_controller($post_type, $params);
