get_attachment_template [ WordPress Function ]
| Returns: |
|
| Defined at: |
|
Retrieve path of attachment template in current or parent template.
The attachment path first checks if the first part of the mime type exists. The second check is for the second part of the mime type. The last check is for both types separated by an underscore. If neither are found then the file 'attachment.php' is checked and returned.
Some examples for the 'text/plain' mime type are 'text.php', 'plain.php', and finally 'text_plain.php'.
Source
<?php
function get_attachment_template() {
global $posts;
$type = explode('/', $posts[0]->post_mime_type);
if ( $template = get_query_template($type[0]) )
return $template;
elseif ( $template = get_query_template($type[1]) )
return $template;
elseif ( $template = get_query_template("$type[0]_$type[1]") )
return $template;
else
return get_query_template('attachment');
}
?>
Examples [ wp-snippets.com ]
Top Google zoekresultaten
- Function Reference/get attachment template « WordPress Codex
Description. Retrieve path of attachment template in current or parent template. The attachment path first checks if the first part of the mime type exists.
codex.wordpress.org - Function Reference « WordPress Codex
... get_archive_template · get_attachment_template · get_author_template · get_category_template|get_category_template · get_comments_popup_template ...
codex.wordpress.org - get_attachment_template | A HitchHackers guide through WordPress
Feb 11, 2011 ... The attachment path first checks if the first part of the mime type exists. The second check is for the second part of the mime type. The last check ...
hitchhackerguide.com - 常用函数-get_attachment_template() | WordPress啦!
常用函数-get_attachment_template(). 说明. 检索当前模板或父模板的附件模板路径 。 附件路径首先查找mime类型的第一部分是否存在,接着超找第二部分。最后查找 ...
www.wordpress.la