Attachment Tags
-
Hi all,
I have added post_tags to my attachments and that is all working fine. The problem is when I click the tag it goes to the correct URL but it does not show the attachments associated with the tag. Do I need to filter the loop like one would do with a custom post type (pre_get_posts) or do I need to write some kind of query in my loop-tag.php? Can anybody help?
-
I still haven’t figured this out. Basically I want to show a loop of attachments that are tagged by that term. Any help is appreciated.
That’s because the tag look looks for POSTS specifically. If you look in your DB, you’ll see the ‘type’ field has different values: post, page, revision, attachment, etc etc. The loop looks just for posts.
You would have to rebuild the loop to scan for attachments: http://wordpress.org/support/topic/referring-to-an-attachment-file-in-the-loop?replies=3
And even then I’m not sure how much you’d have to re-invent to get tags working right.
Thanks for the response Ipstenu. I understand that the query looks for the post by default. I can also get it to display attachments and attachments by terms but I would have to right a query for each specific term. I know there is a way to tell the query to treat the attachments as posts I just don’t know how to make it generate a list of attachments according to the term. Thanks again
Like I said, you’ve got some re-invention going on. 🙁 You will need to build your own query that pulls the attachments (see the link I posted? It does that). In theory you would need to write an SQL call to use the post-ID from that query to summon the postmeta table and pull in the tags.
The topic ‘Attachment Tags’ is closed to new replies.