Search code examples
javascriptphpwordpresswordpress-themingcustom-wordpress-pages

Getting images from wordpress post and showing through Javascript


I've been working on a webcomic website for a while now but for a few weeks now I've been stuck on the comic viewing part.

In theory, what I'm trying to do is grab images from the WordPress post and store them in a PHP Array variable and show 1 element of the Array at a time through Javascript.

Can anyone help out?


Solution

  • Since many details are not mentioned I will try to answer as best as I can from whatever you have mentioned.

    In case I have access to theme functions I will try to get the post attachments as array of URLs and render them wherever I want to with the help of slider to achieve one image at a time. In case I am not able to extract the post attachments I will get the url of post, get the html crawl to container which holds the post content and extract the image tags and display them where ever I want to again with the help of slider