| | 84 | * Will attempt to retrieve templates specific to the query vars that are |
| | 85 | * present in the URL returning a 404 error. For example, if the tag query |
| | 86 | * var is set, 404-tag.php and 404-archive.php will be returned in addition |
| | 87 | * to the default 404.php. |
| | 88 | * |
| | 89 | * Works by looping through the '$checks' array and checking to see if each |
| | 90 | * query var is set. If one is, the template slugs for that query var will be |
| | 91 | * looped through to build the template filenames. |
| | 92 | * |
| 94 | | return get_query_template('404'); |
| | 103 | |
| | 104 | $checks = array( |
| | 105 | 'taxonomy' => array( 'taxonomy-%s', 'taxonomy', 'archive' ), |
| | 106 | 'attachment' => array( 'attachment', 'single', 'singular' ), |
| | 107 | 'attachment_id' => array( 'attachment', 'single', 'singular' ), |
| | 108 | 'p' => array( 'single', 'singular' ), |
| | 109 | 'name' => array( 'single', 'singular' ), |
| | 110 | 'page_id' => array( 'page', 'singular' ), |
| | 111 | 'post_type' => array( 'single-%s', 'single', 'singular' ), |
| | 112 | 'cat' => array( 'category', 'archive' ), |
| | 113 | 'category_name' => array( 'category', 'archive' ), |
| | 114 | 'tag' => array( 'tag', 'archive' ), |
| | 115 | 'author' => array( 'author', 'archive' ), |
| | 116 | 'm' => array( 'date', 'archive' ), |
| | 117 | 'year' => array( 'date', 'archive' ), |
| | 118 | 'monthnum' => array( 'date', 'archive' ), |
| | 119 | 'day' => array( 'date', 'archive' ), |
| | 120 | ); |
| | 121 | |
| | 122 | $templates = array(); |
| | 123 | |
| | 124 | foreach ( $checks as $query_var => $template_slugs ) { |
| | 125 | if ( $query_var = get_query_var( $query_var ) ) { |
| | 126 | foreach ( $template_slugs as $template_slug ) { |
| | 127 | $templates[] = '404-' . sprintf( $template_slug, $query_var ) . '.php'; |
| | 128 | } |
| | 129 | break; |
| | 130 | } |
| | 131 | } |
| | 132 | |
| | 133 | $templates[] = '404.php'; |
| | 134 | |
| | 135 | return get_query_template( '404', $templates ); |