Archived topic
Random Stat & image in sidebar
3 replies · Started by Brad on July 11, 2022
Hello - I'd like to some fuctionality to a site that's simlar to this: https://www.feednovascotia.ca/hungry-for-change
The sidebar has a statistic and images that changes if the page is refreshed.
Maybe too tall an order without super custoimzed PHP but would be cool to create a block or hook element that pulls text and an image from an array in a custom Snippet.
Thanks!
Hi Brad,
Yes, you would need custom code or a third party plugin to achieve as such.
For one, you can use JS to alter the text randomly, and then alter the source of the image through CSS as well.
Another approach as you’ve mentioned is through PHP. But I think you would need to create a Custom Post type or a post is fine as well. What’s important is that it should have custom fields for the images and the “statistics”. Then, you can just make a logic to retrieve them randomly.
Hope this clarifies!
Thanks Fernando - I looked at some third party and they were not quite was I as looking for.. I've used PODS for custom posts and fields and templating before so I'll look at this route. Your Hooks support shortcode so I'll spend a bit more time exploring this.
Cheers
You’re welcome Brad! Cheers!