Display title (and link) to a file in loop / excerpt (5 posts)

  1. Paul Wright
    Posted 6 years ago #


    I'm in search of a way to pull any files (other than images) that are added to a post and display the title as a direct link to it in my template file.

    I want to avoid custom fields, because I won't be the person making the posts.

    Basically, if I attach a PDF to a post, I would like to add a link to that PDF below the excerpt in "posts" page. It would look something like this:


    Post Title #1
    File 1 File 2

    Post Title #2
    Excerpt #2
    File 3 File 4


    I'm assuming something similar to what I've done with automatically grabbing the first image and displaying it as the thumbnail on the posts page. But in this case it would search for files by type and display the link to that file (if any)..instead of the thumbnail of a photo.


  2. Paul Wright
    Posted 6 years ago #

    Does anyone have an idea about a solution to this?

    I'd like to be able to find a way to grab all the files attached to a post and provide links to those files in the loop.


  3. Paul Wright
    Posted 6 years ago #

    I have searched around and there doesn't seem to be any easy way of grabbing files that are attached to posts and outputting them in the loop as a link.

    The loop can output the post title, the post excerpt and even post thumbnail, but I'd like to be able to include links to any files I attached too.


  4. Michael
    Forum Moderator
    Posted 6 years ago #

  5. Paul Wright
    Posted 6 years ago #

    That link is great, and the comments take it even further - thanks very much. I did a fair amount of digging to no avail.

    I haven't used the code yet, but on first look it does exactly what I want.

    Thanks again

Topic Closed

This topic has been closed to new replies.

About this Topic