[Support request] Can I display multiple images from one single hook? (different image per post)

Home Forums Support [Support request] Can I display multiple images from one single hook? (different image per post)

Home Forums Support Can I display multiple images from one single hook? (different image per post)

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #2393540
    Eric

    Hi GeneratePress Team! I hope you guys are all doing well…

    I had a question about a rather specific use case I am trying to solve. Let’s say I have 1000 different posts on my WP site. I also have 1000 unique images all loaded into my WP media folder. How can I use GeneratePress Hook Elements to “assign” 1 image per post on my site?

    I am imagining that I could load a list of URLs into my functions.php, and then create a single hook element. Then GeneratePress would take one unique image URL from that list and display it inside that single hook, per post. What I can’t figure out is that I need the hook to take different URLs from the list, or a random image, per post… and NOT display the same images over and over. It would need to show a different image for the next post, and the next as well, and so on going down the list. Is this possible?

    Hoping for your guidance! Thanks again GPress Team and keep up the great work!

    #2393797
    David
    Staff
    Customer Support

    Hi there,

    why not use the Featured Image on the individual post ?
    Or as an alternative to that, register a Custom Field to store the image.

    Either of those method will store the Image ID in the Posts meta data.

    Let me know

    #2394254
    Eric

    Yes, well, I didn’t really want to use the featured image because I’m planning on placing the elements down the page, so I can test them in different locations in the content. Featured images at the top of the page will be different, and these are more of extra images that I will display in my content using the different GPress element hook locations. How would the custom field solution work exactly? Does that accomplish it? Thanks again for your time and attention!

    #2394379
    Ying
    Staff
    Customer Support

    Hum..I still don’t quite understand what you are trying to do.

    Are you trying to automatically insert different images to different locations of the post content area?

    If so, GP doesn’t have hooks available inside the post content, so this won’t work by using GP hooks.

    Custom field is a WP feature, there’re also plenty plugins offers the same feature with more friendly user interface, for more info:
    https://wordpress.org/support/article/custom-fields/

    #2394779
    Eric

    Are you trying to automatically insert different images to different locations of the post content area?

    Yes this is exactly what I’m trying to do! the elements hook doesn’t have the ability to post in content out of the box but you can combine it with Ad Inserter to get this functionality. Regardless, it still has the option to select things like after_content, after_entry_title, and others so I am hoping to do exactly that: insert images automatically sitewide from a list of URLs, without having to manually update each and every post. Using GPress elements also gives me the ability to turn them all off at once if needed.

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