I've been trying to come up with a way to add a list of PDF's from the Media Library in WordPress. It's for a list of newsletters which will start with the most recent, and list about 5. I want it to list with a title and that title be a hyperlink to the document. So when a visitor clicks the link it will download the PDF.
I have tried the "get_posts" route but can't figure it out at all. Currently what I'm doing is inserting the PDF's into a post with a category of "newsletter" and then having a separate loop to pull them up on the page. I've almost got this working, but it's not linking properly. So I was hoping for some help.
My code so far looks like this:
<h3>Newsletters</h3>
<ul>
<?php query_posts('category_name=newsletter&posts_per_page=5'); ?>
<?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
<li>
<a href="<?php echo wp_get_attachment_url(the_ID()); ?>" title="<?php echo esc_attr( get_the_title() ); ?>" rel="attachment">
<?php echo esc_attr( get_the_title() ); ?></a>
</li>
<?php endwhile; ?>
</ul>
The part I just can't seem to get right is:<?php echo wp_get_attachment_url(the_ID()); ?>