Title: Attachment Loop Stopped Working
Last modified: August 22, 2016

---

# Attachment Loop Stopped Working

 *  [petroglyphic](https://wordpress.org/support/users/petroglyphic/)
 * (@petroglyphic)
 * [11 years, 2 months ago](https://wordpress.org/support/topic/attachment-loop-stopped-working/)
 * We’ve been using the following loop to display lists of attachments to subpages:
 *     ```
       <ul>[loop id="35475" status="any"][attached orderby="title"]
       	<li><a href="[field url]" target="_blank">[field title]</a></li>
       [/attached][/loop]</ul>
       ```
   
 * It worked until a few days ago, probably the last update. Displays nothing now.
   This still works on the subpage itself:
 *     ```
       <ul>[attached orderby="title"]
       	<li><a href="[field url]" target="_blank">[field title]</a></li>
       [/attached]</ul>
       ```
   
 * I checked it against the documentation, couldn’t find the problem. What do I 
   need to change?
    This page should have two lists of links to attachments: [. This is one of the subpages with the attached loop on the page: ](http://www.sierranevada.edu/academics/teacher-education/ted-resources/class-syllabi/)
   [](http://www.sierranevada.edu/academics/teacher-education/ted-resources/class-syllabi/2015-spring-ted-syllabi-reno/)
 * Thanks, Susan
 * [https://wordpress.org/plugins/custom-content-shortcode/](https://wordpress.org/plugins/custom-content-shortcode/)

Viewing 13 replies - 1 through 13 (of 13 total)

 *  Plugin Author [Eliot Akira](https://wordpress.org/support/users/miyarakira/)
 * (@miyarakira)
 * [11 years, 2 months ago](https://wordpress.org/support/topic/attachment-loop-stopped-working/#post-5906423)
 * Thank you for telling me about this. So it looks like [attached] is not working
   inside the loop? I’ll look into it and let you know what I find out.
 * In the meantime, can you tell me the output of this?
 *     ```
       [loop id="35475" status="any"]
         [if attached]
           The post has attachments.
         [else]
           The post doesn't have attachments.
         [/if]
       [/loop]
       ```
   
 * I just want to narrow down where the issue is coming from.
 *  Plugin Author [Eliot Akira](https://wordpress.org/support/users/miyarakira/)
 * (@miyarakira)
 * [11 years, 2 months ago](https://wordpress.org/support/topic/attachment-loop-stopped-working/#post-5906432)
 * I tested [loop] with specific ID and [attached] – they’re working on my end. 
   I wonder what is different in your case.. The last several plugin updates just
   added new parameters for [loop] and didn’t change anything with [attached] – 
   so I don’t think that’s where it’s coming from.
 * Has anything changed with the post itself?
 *  Thread Starter [petroglyphic](https://wordpress.org/support/users/petroglyphic/)
 * (@petroglyphic)
 * [11 years, 2 months ago](https://wordpress.org/support/topic/attachment-loop-stopped-working/#post-5906516)
 * The if/else loop you sent doesn’t return anything. Nothing had changed with the
   post itself for at least several weeks. (It displays links to class syllabi, 
   I update at the beginning of each semester and that’s it till the next.) We have
   another page which lists attachments to 4 subpages with the same loop syntax 
   which is also not working.
 * We installed W3 Total Cache last week – are you aware of any conflicts between
   your plugin and that one?
 * The page links in my first post got screwed up –
    This page should have two lists
   of links to attachments: [http://www.sierranevada.edu/academics/teacher-education/ted-resources/class-syllabi/](http://www.sierranevada.edu/academics/teacher-education/ted-resources/class-syllabi/)
   One of the subpages with the attached loop on the page: [http://www.sierranevada.edu/academics/teacher-education/ted-resources/class-syllabi/2015-spring-ted-syllabi-reno/](http://www.sierranevada.edu/academics/teacher-education/ted-resources/class-syllabi/2015-spring-ted-syllabi-reno/)
 * Thanks, Susan
 *  Plugin Author [Eliot Akira](https://wordpress.org/support/users/miyarakira/)
 * (@miyarakira)
 * [11 years, 2 months ago](https://wordpress.org/support/topic/attachment-loop-stopped-working/#post-5906520)
 * I see, that’s odd that the code above didn’t return anything – it should have
   displayed one or the other message.
 * Does it display any field from this specific post?
 *     ```
       [loop id="35475" status="any"]
         Post title: [field title]
         Post ID: [field id]
         [if attached]
           The post has attachments.
         [else]
           The post doesn't have attachments.
         [/if]
       [/loop]
       ```
   
 * If this displays nothing, then it means [loop] is not finding the post for some
   reason. Can you confirm that it’s the correct post ID?
 *  Plugin Author [Eliot Akira](https://wordpress.org/support/users/miyarakira/)
 * (@miyarakira)
 * [11 years, 2 months ago](https://wordpress.org/support/topic/attachment-loop-stopped-working/#post-5906521)
 * The [loop] uses a native WordPress function to get posts, and I’m not aware of
   any plugin conflict with W3 Total Cache.
 * Just to narrow down the issue, does this display anything?
 *     ```
       Post title: [content id="35475" status="any" field="title"]
       ```
   
 * If this displays nothing and it’s the correct post ID, that sounds like it could
   be another plugin interfering with the normal process of getting posts.
 *  Thread Starter [petroglyphic](https://wordpress.org/support/users/petroglyphic/)
 * (@petroglyphic)
 * [11 years, 2 months ago](https://wordpress.org/support/topic/attachment-loop-stopped-working/#post-5906536)
 * Post ID is correct.
 * The code you posted above works. [content id=””] is in use in many places and
   working. (I like your plugin!) [attached] without the loop (to display on the
   same page) works.
 * This doesn’t work, if that says anything:
    [loop id=”35475″ status=”any”] [field
   title] [/loop]
 *  Plugin Author [Eliot Akira](https://wordpress.org/support/users/miyarakira/)
 * (@miyarakira)
 * [11 years, 2 months ago](https://wordpress.org/support/topic/attachment-loop-stopped-working/#post-5906537)
 * Yes, this last point is very strange, and I think it must be related to the issue.
   Why isn’t the [loop] finding the post.. I’ll check the loop function to see if
   I can find anything that could be causing this.
 * Is there anything about this specific post? I’m guessing you use status=”any”
   because the post is in _draft_ status. So I’ll see if this could be related. 
   Does it make a difference if the post is _published_?
 * Also, if you could help me figure this out, could you test the same code with
   another post?
 *  Thread Starter [petroglyphic](https://wordpress.org/support/users/petroglyphic/)
 * (@petroglyphic)
 * [11 years, 2 months ago](https://wordpress.org/support/topic/attachment-loop-stopped-working/#post-5906555)
 * Getting weirder and weirder. Must be some kind of conflict.
 * [loop id=”35470″]
    [field title] [/loop] returns the title ONLY if 35470 not 
   hierarchical (a normal post) or is a top level page or special post. It doesn’t
   matter what the relationship is between 35470 and the page the loop is on, if
   35470 has a parent the loop returns nothing.
    - [loop id=”35470”][attached count=”5″ orderby=”title”]
    - [[field title]](https://wordpress.org/support/topic/attachment-loop-stopped-working/[field url]?output_format=md)
    - [/attached][/loop]
 * is returning a list, but none of the parameters of [loop] and [attached] are 
   registering. It’s a list of many (probably all) of the images which are attached
   in the site, not ordered by title. It doesn’t include attached documents, which
   we have a lot of. It doesn’t matter if 35470 is a page, post, or special post
   type, or whether it’s an orphan, patriarch, or the baby of a big family.
 *  Thread Starter [petroglyphic](https://wordpress.org/support/users/petroglyphic/)
 * (@petroglyphic)
 * [11 years, 2 months ago](https://wordpress.org/support/topic/attachment-loop-stopped-working/#post-5906556)
 * Also, debug.log is not registering any fatal php errors, or anything including“
   custom-content-shortcode”.
 *  Plugin Author [Eliot Akira](https://wordpress.org/support/users/miyarakira/)
 * (@miyarakira)
 * [11 years, 2 months ago](https://wordpress.org/support/topic/attachment-loop-stopped-working/#post-5906565)
 * Thank you for the detailed feedback – this is very helpful in finding the cause
   of the issue.
 * I think the clue is in the first point you mentioned:
 * > ..returns the title ONLY if 35470 is not hierarchical (a normal post) or is
   > a top level page or special post..if 35470 has a parent the loop returns nothing.
 * It must be related to hierarchical posts.
 * The second point is weird too..
 * > It’s a list of many (probably all) of the images which are attached in the 
   > site.
 * So, in the first case it’s returning nothing, and in the second, returning all!
   I’ll get back to you with what I find.
 *  Plugin Author [Eliot Akira](https://wordpress.org/support/users/miyarakira/)
 * (@miyarakira)
 * [11 years, 2 months ago](https://wordpress.org/support/topic/attachment-loop-stopped-working/#post-5906581)
 * I believe I’ve isolated the issue in the first point. There was a default parameter
   that was getting only top-level posts, excluding any children, grandchildren,
   or further descendants. In the latest plugin update, I changed it so descendants
   are included by default. This changes behavior from previous versions, so I put
   a note in the upgrade notice. Hopefully, people will read it, in case it affects
   how they use the [loop].
 * For the second point – I’m not sure if it is the same issue as the first. Please
   try the newest version to see if it is corrected also.
 *  Thread Starter [petroglyphic](https://wordpress.org/support/users/petroglyphic/)
 * (@petroglyphic)
 * [11 years, 2 months ago](https://wordpress.org/support/topic/attachment-loop-stopped-working/#post-5906598)
 * Installed the upgrade. The issue with the loop only pulling the titles of top-
   level pages is fixed. The situation with the attachments hasn’t changed.
 * Thanks, Susan
 *  Plugin Author [Eliot Akira](https://wordpress.org/support/users/miyarakira/)
 * (@miyarakira)
 * [11 years, 2 months ago](https://wordpress.org/support/topic/attachment-loop-stopped-working/#post-5906657)
 * Hello, sorry for taking so long to get back to you.
 * I’ve tested both [loop] and [attached], and they’re working correctly on my end.
   I used the exact same code (except for the post ID).
 *     ```
       [loop id="35470”][attached count="5" orderby="title"]
       [field title]
       [/attached][/loop]
       ```
   
 * So, if that’s not working, it must be something specific to your setup – possibly
   a plugin conflict..?

Viewing 13 replies - 1 through 13 (of 13 total)

The topic ‘Attachment Loop Stopped Working’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/custom-content-shortcode_766976.svg)
 * [Custom Content Shortcode](https://wordpress.org/plugins/custom-content-shortcode/)
 * [Support Threads](https://wordpress.org/support/plugin/custom-content-shortcode/)
 * [Active Topics](https://wordpress.org/support/plugin/custom-content-shortcode/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/custom-content-shortcode/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/custom-content-shortcode/reviews/)

## Tags

 * [attached](https://wordpress.org/support/topic-tag/attached/)

 * 13 replies
 * 2 participants
 * Last reply from: [Eliot Akira](https://wordpress.org/support/users/miyarakira/)
 * Last activity: [11 years, 2 months ago](https://wordpress.org/support/topic/attachment-loop-stopped-working/#post-5906657)
 * Status: not resolved