UPDATE: Please see WP plugin to make gallery display PDFs, .docs, .xls, more!
I run the Penn Med UltraSounds website, and I needed a way to display a list of pdf’s. As far as I know, you can upload non-image media (e.g., pdf’s and word docs) to the gallery, but its baseline allows you to display only images; you have to individually insert other media types rather than inserting the whole gallery.
The advantage of using the gallery to display media is that you can update the media list and display it sorted in various ways, for example by title or by date. Each gallery is unique to the associated post. So, you’d think that someone would have made a plugin or made this functionality accessible for other file types. I couldn’t find any, though. I just want a simple list of links!
So what did I do? After a mean monster breakfast of steak (that’s what Chris eats for breakfast, so that’s what I get), I decided to see if I could modify the code to enable me to do what I want. The solution, though in rough form, is surprisingly simple: I take advantage of the existing gallery shortcode by adding the following to the wp-includes/media.php, just below the $attachments = get_children..., around line 643:
// ========================== anh hack 2010-05 =========================
// get gallery to display list of links, eg for pdf's
if ( isset( $attr['linklist'] ) ) {
$listfiletype = $attr['linklist'];
if ( !$attr['linklist'] )
unset( $attr['linklist'] );
$attachments = get_children( array('post_parent' => $id,
'post_status' => 'inherit', 'post_type' => 'attachment',
'post_mime_type' => $listfiletype, 'order' => $order,
'orderby' => $orderby) );
}
// ========================== end anh hack =============================
Then, using the gallery short code, specify the type of file in the option linklist. This file type can be found in the details for the media item, underneath its title. In the MySQL database table wp-posts, it is the value under post-mime-type. Here is a screenshot:
For example, to display pdf’s and order alphabetically by title, use .
Hope this helps! Let me know if you have questions. Time permitting and curiosity motivating, I will attempt to make this into a plugin. I foresee that dealing with the myriad ways people might need the plugin will make the task exponentially more difficult, but still, it could be fun =)

I tried using your trick. i don’t think I couldn’t figure out how to do it, and I’m a pretty savvy guy. Perhaps you can upload a youtube video using camtasia to capture your screenshots, that way someone like I can view it on video step by step. Email me if this ever comes to fruition
@the guy above me and anyone else.
For WordPress 3.1.1, place this snippet on line 809.
if ( isset( $attr['linklist'] ) )
{
$listfiletype = $attr['linklist'];
if ( !$attr['linklist'] )
unset( $attr['linklist'] );
$attachments = get_children( array(‘post_parent’ => $id,
‘post_status’ => ‘inherit’, ‘post_type’ => ‘attachment’,
‘post_mime_type’ => $listfiletype, ‘order’ => $order,
‘orderby’ => $orderby) );
}
Works perfectly. Thanks OP!
Thanks Ed! WordPress evolves so quickly I can’t keep up, so I definitely appreciate your help!
Pingback: Pasit - Logoentwürfe für Morpheus
Hi, if you ever did make this into a plugin I’d love to see it! Thanks for the solution anyhow.
This is a great solution, but modifying the core is not something I want to have to do every time there’s an update to WordPress. What would be required to make this into a plugin? I’m not much of a coder myself.
After some more digging I found another plugin that allows you to list PDFs and other file types, using the native galleries: http://skyphe.org/code/wordpress/file-gallery/