[Resolved] what is the hook for an attachment page

Home Forums Support what is the hook for an attachment page

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #1048019
    Robin

    Hello! I am still working on setting up a custom layout to be displayed when a visitor clicks on a thumbnail in one of the multiple galleries there will be on the website. Some of those galleries will have a lightbox feature, but others won’t. For the galleries that don’t use a lightbox, I want to customize the page that appears when a visitor clicks a thumbnail image.

    1. there will be a special menu for that page, with the same styling and location as the regular navigation, but with only two links

    2. the page layout (the attachment page is technically a post, correct? so I will restyle that page in the child theme, as “attachment.php”? is that correct, or will using a hook and element be enough?

    3. layout very simple: no footer, special menu as above, image at large size, with image meta data underneath: caption OR title (I am making those the same in the media library) AND description.

    4. Using a hook to set up that element, what is that hook? wp_attachment_image?? or?

    5. I have been researching customizing the image-attachment page, and there are things about php I don’t understand. I know that I need to fetch the actual image that the thumbnail clicked on represents, fetch the meta data for that image, and then display all that in html form…

    Your assistance and advice much appreciated!

    Apologies for my newbie-ness. I do retain what I learn, and repeat those lessons until I no longer need assistance at that level.

    Thank you!

    #1048270
    David
    Staff
    Customer Support

    Hi there,

    this is out of usual scope, but in this instance i thought it easier to provide a basic attachment.php template that you can install in your child theme to get you started.

    The file can be found here:
    https://gist.github.com/diggeddy/e487553c6b5749728957dad36393db4c

    This will output the Attachment image full size, followed by Title and Description.
    Its built on the standard page template so things like sidebars and footer are still present.
    Thought it better they remain in the template for future scope. You can remove them using the Layout Element with a Display Rule of Media > All Media.

    For the different navigation i would recommend using the Secondary Navigation for your two links. Again you can use the Layout Element to remove the navs accordingly.

    #1048283
    Robin

    wow! excellent! thank you very much!

    #1048292
    David
    Staff
    Customer Support

    You’re welcome – i left some comments so you can at least see what is what and can compare it to the single.php its built off of.

    #1048308
    Robin

    yes, those are most helpful.

    have added /draggable=”false”/ to img as first foray into working with the template.

    #1049252
    Robin

    Just wanted to say THANK YOU again. From what you provided, I have been able to do EVERYTHING on my wish list for the single-image pages.

    Lots still to do on fine tuning and debugging of the website etc etc but: the basics are set, and I will continue learning from that template.

    So very much appreciated.

    Robin

    #1049502
    David
    Staff
    Customer Support

    You’re very welcome – happy to be of help

Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.