I’m currently using Types with WordPress. The requirement is for me to be able to place an image – uploaded in Types- after every 2 paragraphs.
Now, I know how to pull in the field from Types. What I’m not sure about, (perhaps this is done with Javascript?) is how to then auto-place one image after 2 paragraphs, then another image after 4, etc.
Is this possible? My very limited jQuery knowledge informs me it might have something to do with an nth-child selector or something? But this is just a guess.
Any help would be greatly appreciated.
Here’s an example of how to do it: http://jsfiddle.net/tkK6y/
Let’s say you have an array of image URLS:
And a div with
n
paragraphs:You can loop through every second paragraph and insert images after each one like this:
There is a way to do this without jquery, only using php and the would be to do a custom loop where you would define a incrementing variable and you would display a result every other post using a basic math function like so: