Linking to Parent(s) in Image Attachment Posts

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 either 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 - as those links are already in the main menu system.

In short, I need links back to the immediate parent and, ideally, the immediate parent’s parent (hopefully that makes sense).

These links will be displayed beneath the image and description in the image attachment page (image.php). The goal here is to have links from the image attachment page back to the “photo gallery” and also the “heavy content page.” So the end result I’m hoping for should something like this:

BIG IMAGE

[description]

Back to [immediate parent - which is the photo gallery]
Return to [next parent up - which is the “heavy content page” and which is the parent of the “photo gallery”]

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 image.php. And the
“Heavy Content Pages” and “Photo Gallery Pages” all have different
topics.

Any help would be appreciated. Sorry for the long first post, but I’m trying to be specific since I suspect this type of linking is “unique.”

Thanks

Jim

Edit - I should add that the theme I’m using is my “own theme.” Not sure if that makes a difference or not in this case, but thought I’d let everyone know.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.