equal
deleted
inserted
replaced
57 * @since 1.5.0 |
57 * @since 1.5.0 |
58 * |
58 * |
59 * @return string |
59 * @return string |
60 */ |
60 */ |
61 function get_archive_template() { |
61 function get_archive_template() { |
62 $post_type = get_query_var( 'post_type' ); |
62 $post_types = get_query_var( 'post_type' ); |
63 |
63 |
64 $templates = array(); |
64 $templates = array(); |
65 |
65 |
66 if ( $post_type ) |
66 foreach ( (array) $post_types as $post_type ) |
67 $templates[] = "archive-{$post_type}.php"; |
67 $templates[] = "archive-{$post_type}.php"; |
68 $templates[] = 'archive.php'; |
68 $templates[] = 'archive.php'; |
69 |
69 |
70 return get_query_template( 'archive', $templates ); |
70 return get_query_template( 'archive', $templates ); |
71 } |
71 } |
80 function get_author_template() { |
80 function get_author_template() { |
81 $author = get_queried_object(); |
81 $author = get_queried_object(); |
82 |
82 |
83 $templates = array(); |
83 $templates = array(); |
84 |
84 |
85 $templates[] = "author-{$author->user_nicename}.php"; |
85 if ( $author ) { |
86 $templates[] = "author-{$author->ID}.php"; |
86 $templates[] = "author-{$author->user_nicename}.php"; |
|
87 $templates[] = "author-{$author->ID}.php"; |
|
88 } |
87 $templates[] = 'author.php'; |
89 $templates[] = 'author.php'; |
88 |
90 |
89 return get_query_template( 'author', $templates ); |
91 return get_query_template( 'author', $templates ); |
90 } |
92 } |
91 |
93 |
104 function get_category_template() { |
106 function get_category_template() { |
105 $category = get_queried_object(); |
107 $category = get_queried_object(); |
106 |
108 |
107 $templates = array(); |
109 $templates = array(); |
108 |
110 |
109 $templates[] = "category-{$category->slug}.php"; |
111 if ( $category ) { |
110 $templates[] = "category-{$category->term_id}.php"; |
112 $templates[] = "category-{$category->slug}.php"; |
|
113 $templates[] = "category-{$category->term_id}.php"; |
|
114 } |
111 $templates[] = 'category.php'; |
115 $templates[] = 'category.php'; |
112 |
116 |
113 return get_query_template( 'category', $templates ); |
117 return get_query_template( 'category', $templates ); |
114 } |
118 } |
115 |
119 |
128 function get_tag_template() { |
132 function get_tag_template() { |
129 $tag = get_queried_object(); |
133 $tag = get_queried_object(); |
130 |
134 |
131 $templates = array(); |
135 $templates = array(); |
132 |
136 |
133 $templates[] = "tag-{$tag->slug}.php"; |
137 if ( $tag ) { |
134 $templates[] = "tag-{$tag->term_id}.php"; |
138 $templates[] = "tag-{$tag->slug}.php"; |
|
139 $templates[] = "tag-{$tag->term_id}.php"; |
|
140 } |
135 $templates[] = 'tag.php'; |
141 $templates[] = 'tag.php'; |
136 |
142 |
137 return get_query_template( 'tag', $templates ); |
143 return get_query_template( 'tag', $templates ); |
138 } |
144 } |
139 |
145 |
154 * |
160 * |
155 * @return string |
161 * @return string |
156 */ |
162 */ |
157 function get_taxonomy_template() { |
163 function get_taxonomy_template() { |
158 $term = get_queried_object(); |
164 $term = get_queried_object(); |
159 $taxonomy = $term->taxonomy; |
165 |
160 |
166 $templates = array(); |
161 $templates = array(); |
167 |
162 |
168 if ( $term ) { |
163 $templates[] = "taxonomy-$taxonomy-{$term->slug}.php"; |
169 $taxonomy = $term->taxonomy; |
164 $templates[] = "taxonomy-$taxonomy.php"; |
170 $templates[] = "taxonomy-$taxonomy-{$term->slug}.php"; |
|
171 $templates[] = "taxonomy-$taxonomy.php"; |
|
172 } |
165 $templates[] = 'taxonomy.php'; |
173 $templates[] = 'taxonomy.php'; |
166 |
174 |
167 return get_query_template( 'taxonomy', $templates ); |
175 return get_query_template( 'taxonomy', $templates ); |
168 } |
176 } |
169 |
177 |
278 function get_single_template() { |
286 function get_single_template() { |
279 $object = get_queried_object(); |
287 $object = get_queried_object(); |
280 |
288 |
281 $templates = array(); |
289 $templates = array(); |
282 |
290 |
283 $templates[] = "single-{$object->post_type}.php"; |
291 if ( $object ) |
|
292 $templates[] = "single-{$object->post_type}.php"; |
284 $templates[] = "single.php"; |
293 $templates[] = "single.php"; |
285 |
294 |
286 return get_query_template( 'single', $templates ); |
295 return get_query_template( 'single', $templates ); |
287 } |
296 } |
288 |
297 |
301 * |
310 * |
302 * @return string |
311 * @return string |
303 */ |
312 */ |
304 function get_attachment_template() { |
313 function get_attachment_template() { |
305 global $posts; |
314 global $posts; |
306 $type = explode('/', $posts[0]->post_mime_type); |
315 |
307 if ( $template = get_query_template($type[0]) ) |
316 if ( ! empty( $posts ) && isset( $posts[0]->post_mime_type ) ) { |
308 return $template; |
317 $type = explode( '/', $posts[0]->post_mime_type ); |
309 elseif ( $template = get_query_template($type[1]) ) |
318 |
310 return $template; |
319 if ( ! empty( $type ) ) { |
311 elseif ( $template = get_query_template("$type[0]_$type[1]") ) |
320 if ( $template = get_query_template( $type[0] ) ) |
312 return $template; |
321 return $template; |
313 else |
322 elseif ( $template = get_query_template( $type[1] ) ) |
314 return get_query_template('attachment'); |
323 return $template; |
|
324 elseif ( $template = get_query_template( "$type[0]_$type[1]" ) ) |
|
325 return $template; |
|
326 } |
|
327 } |
|
328 |
|
329 return get_query_template( 'attachment' ); |
315 } |
330 } |
316 |
331 |
317 /** |
332 /** |
318 * Retrieve path of comment popup template in current or parent template. |
333 * Retrieve path of comment popup template in current or parent template. |
319 * |
334 * |