[wp-testers] Attachment Pages for Non-Standard Post Format Types

Otto otto at ottodestruct.com
Tue Jan 11 18:36:58 UTC 2011


Agreed, for attachment posts, using the mime type makes way more sense.

Note that if you need the mime type in the Loop or something, you can
reference $post->post_mime_type (sorry, no pretty function for this).
You could even split it along the / if necessary. Like so:

$type = explode('/', $post->post_mime_type);
if ($type[0] == 'audio') ...
if ($type[0] == 'video') ...

-Otto


On Tue, Jan 11, 2011 at 1:22 PM, Nathaniel Taintor
<goldenapplesdesign at gmail.com> wrote:
> In my opinion, the way WordPress currently handles attachments, by
> mime-type, makes more sense for attachments than trying to fit attachments
> into the post format structure.
>
> Attachments of mime-type "audio/mp3", for example, will be served by
> template file audio.php, then mp3.php, then audio_mp3.php, and then finally
> attachment.php. This gives you a chance to handle formats pretty well in
> your theme files.
>
> What use do you have in mind where you would need to check the parent post's
> format in order to display the attachment?


More information about the wp-testers mailing list