Switch language

wpseek.com
A WordPress-centric search engine for devs and theme authors




get_attachment_template [ WordPress Function ]

get_attachment_template ( No parameters )
Returns:
  • (string)
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 ]

Google Arama Sonuçlarý

Dahasý ...

Kullanýcý Tartýþmalarý [ wordpress.org ]

- Bulunamadý -

Yeni bir konu yaz ...

0 User Note(s)

Henüz yok. Ýlk sen ol!

Yeni Ekle ...



HTML5 Powered with CSS3 / Styling, Performance & Integration, and Semantics