Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.
$args = array(
    'post_type' => 'attachment',
    'numberposts' => null,
    'post_status' => null,
    'post_parent' => $post->ID
);
$attachments = get_posts($args);
if ($attachments) {
    foreach ($attachments as $attachment) {
        echo apply_filters('the_title', $attachment->post_title);
        the_attachment_link($attachment->ID, false);
    }
}

In the code above, theres exist a way to get:

  1. All attachments links except featured image.

  2. All PDF attachments links only.

I was reading:

share|improve this question

1 Answer 1

up vote 11 down vote accepted

For the first one, you can add 'exclude' => get_post_thumbnail_id() as a parameter (as shown here).

For the second one, you can add 'post_mime_type' => 'application/pdf', but I'm not sure that would always work, afaik, pdfs have more than one mime type.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.