• Michael D

    (@michael-divine)


    I’ve looked around all over and I really can’t seem to find an answer.

    I am using WP’s native gallery system. Each image opens up in an attachment page. There are previous and next links to go from each image.

    If I use a folder plugin then I can keep the images cycling through JUST the images in the gallery. If I don’t then, it just cycles through ALL the media images (not just the ones I’ve chosen for the gallery.

    here are the problems I am trying to overcome:
    1. How to keep the images JUST cycling through the 10 that are in the WP gallery and not having it just go on and on through the media folders.

    2. How to add a ‘back to main gallery’ button

    3. Which leads to the final question:
    Each gallery has a url that’s like site.com/gallery-name. Clicking an image takes you to site.com/image but I’d like it to be site.com/gallery-name/image

    Which also means the ‘back to main gallery’ button should be able to get the URL of the parent page but I don’t seem to be able to do that.

    PS I know there’s lots of gallery plugins but there’s other things like custom fields, etc, that none of them are able to handle and I can’t style them as cleanly and easily as I’ve already done.

    • This topic was modified 3 years, 10 months ago by Michael D.
Viewing 4 replies - 1 through 4 (of 4 total)
  • Did you write the theme?
    If the theme uses the standard navigation functions, only the images in the gallery are linked, and there is a link back to the gallery page. But the theme can use other functions, so it might not make sense.
    Try going to Customizer and preview a Twenty* theme just to see how the links work.

    As for the URLs, the gallery is on a post or page, which has whatever URL it has. The attachments each have their own independent URL, which has no relation to the gallery page because it can be in several galleries or none.

    You can avoid all this by choosing the gallery option of linking to the image file instead of attachment. Then it’s your choice to use a lightbox plugin that magically puts those into a modal overlay. (Shutter Reloaded or Auto Thickbox Plus both are responsive.)

    Thread Starter Michael D

    (@michael-divine)

    hi joy
    Yes it is using a rather bare bones theme at the moment as I try to get all of this working the way I want it to (before I spend time with design and bells and whistles.)

    “If the theme uses the standard navigation functions, only the images in the gallery are linked, and there is a link back to the gallery page.”

    Is this something to be added to the functions.php file? I did use the 2020 theme for a while before switching over but the same thing was happening.

    “As for the URLs…”

    right so there’s no way to reference the image back to the page it’s linked from?

    As for all the lightbox options – of which there are many – none of them are able to support the custom fields that I want to show. Each is ONLY the image + maybe the caption or description.

    OK, I was misremembering.
    Several of the more recent Twenty* themes use the single.php for the attachments, and the normal navigation link turns into a link back to the gallery page.
    If you look at Twenty Twelve, however, it uses image.php which outputs the Previous and Next links to other images using previous_image_link() and next_image_link() and those look like the URLs you were wanting.
    See https://developer.www.ads-software.com/reference/functions/next_image_link/
    It also gets all the attachment IDs so that the image itself is linked to the next image. (I don’t particularly like that, expecting to see the actual file.)

    Thread Starter Michael D

    (@michael-divine)

    Yes I have that – as mentioned above – but couldn’t figure a way to link back to the main gallery. Anyhow, I abandoned that method and instead added an iframe lightbox window using fancybox. Thanks!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Attachment Page Slug with Parent Page in URL’ is closed to new replies.