The Support Forums will be in read-only mode for a scheduled maintenance window on 01 September 2016 14:00 UTC - 20:00 UTC. More information.

How to display attachments for a group of pages? (1 post)

  1. jondobrien
    Posted 4 years ago #

    Hi All

    I have a wordpress site that has lots of pages with attachments (PDF Datasheets). The pages are structured like this...

    -- Category 1
    ---- Page 1
    ---- Page 2
    -- Category 2
    ---- Page 1
    ---- Page 2

    I have a downloads page that lists ALL the available downloads on the entire website which is a long list, using the code below:

            $args = array(
              'post_type' => 'attachment',
              'post_mime_type' => 'application/pdf',
              'numberposts' => -1,
              'post_status' => null,
              'post_parent' => $post->ID,
              'orderby' => 'title',
              'order' => 'asc'
      $attachments = get_posts($args);
            if ($attachments) {
              foreach ($attachments as $attachment) {
                echo '<li><a href="'.wp_get_attachment_url($attachment->ID).'">';
                echo $attachment->post_title;
                echo '</a></li>';

    I would like to be able to split the list down in to several smaller lists, for example only showing the downloads for the children of 'Category 1'

    Tried adding a post_parent but can't seem to get it to work.

    Any help would be appreciated.



Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Attachments
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic