Linking to Parent(s) in Image Attachment Posts
-
Hello,
I have a photo intensive site. I use (so far) strictly “pages” as the content is relatively static.
What I’m seeking to do is to use the wp_list_pages or get_post_ancestors function to somehow capture and then display the post’s parent (either one level or perhaps two levels up). Here’s an example of the taxonomy and child/parent relationship most of my pages will eventually have across the site.
Home > Large Parent > Smaller Parent > Heavy Content Page > Photo Gallery Page > Image Attachment
What I hope to do is to provide a link back to the “Heavy Content Page” and the “Photo Gallery Page” from all “Image Attachment” posts. The link would have the page title of the “Heavy Content Page” and the “Photo Gallery Page”.
I don’t want links back to the “Home”, “Large Parent” or “Smaller Parent” page.
In short, I need links back to the immediate parent and, ideally, the immediate parent’s parent.
The code or function, however, can’t be limited to one specific parent(s) ID. It needs to be generic for use site wide, since it will be in all image attachment posts that use a custom image.php. And the “Heavy Content Pages” and “Photo Gallery Pages” are all on different topics.
Any help would be appreciated.
Thanks
Jim
- The topic ‘Linking to Parent(s) in Image Attachment Posts’ is closed to new replies.