3 * Loads the correct template based on the visitor's url
6 if ( defined('WP_USE_THEMES') && WP_USE_THEMES )
8 * Fires before determining which template to load.
12 do_action( 'template_redirect' );
15 * Filter whether to allow 'HEAD' requests to generate content.
17 * Provides a significant performance bump by exiting before the page
18 * content loads for 'HEAD' requests. See #14348.
22 * @param bool $exit Whether to exit without generating any content for 'HEAD' requests. Default true.
24 if ( 'HEAD' === $_SERVER['REQUEST_METHOD'] && apply_filters( 'exit_on_http_head', true ) )
27 // Process feeds and trackbacks even if not using themes.
30 * Fired when the template loader determines a robots.txt request.
34 do_action( 'do_robots' );
36 elseif ( is_feed() ) :
39 elseif ( is_trackback() ) :
40 include( ABSPATH . 'wp-trackback.php' );
44 if ( defined('WP_USE_THEMES') && WP_USE_THEMES ) :
46 if ( is_404() && $template = get_404_template() ) :
47 elseif ( is_search() && $template = get_search_template() ) :
48 elseif ( is_front_page() && $template = get_front_page_template() ) :
49 elseif ( is_home() && $template = get_home_template() ) :
50 elseif ( is_post_type_archive() && $template = get_post_type_archive_template() ) :
51 elseif ( is_tax() && $template = get_taxonomy_template() ) :
52 elseif ( is_attachment() && $template = get_attachment_template() ) :
53 remove_filter('the_content', 'prepend_attachment');
54 elseif ( is_single() && $template = get_single_template() ) :
55 elseif ( is_page() && $template = get_page_template() ) :
56 elseif ( is_category() && $template = get_category_template() ) :
57 elseif ( is_tag() && $template = get_tag_template() ) :
58 elseif ( is_author() && $template = get_author_template() ) :
59 elseif ( is_date() && $template = get_date_template() ) :
60 elseif ( is_archive() && $template = get_archive_template() ) :
61 elseif ( is_comments_popup() && $template = get_comments_popup_template() ) :
62 elseif ( is_paged() && $template = get_paged_template() ) :
64 $template = get_index_template();
67 * Filter the path of the current template before including it.
71 * @param string $template The path of the template to include.
73 if ( $template = apply_filters( 'template_include', $template ) )