YMC
Sat 25 July 2009, 09:32 pm GMT +0200
I am trying to make a header for a Wordpress blog that is made up of 5 random images. I tried getting one of the WP widgets to work and while it did not throw any errors, it didn't display any of the images either.
After spending way too long messing with it, I thought maybe I could do my own thing and come up with exactly what I wanted instead of making something else work.
I think I may have stumbled onto a really slick way to generate the random numbers except my efforts lead to no image being displayed either. lol
So, here's what I've got...
A sub-directory in my theme's directory called random-image. In it are files named 1.jpg, 2.jpg, 3.jpg etc.
I'm getting a random number ($random_1).
I had hoped I could add on the directory and .jpg extension when making the image display. That didn't seem to work so I created another variable $file_1 and took the random number and added ".jpg" to it. Again, no luck on getting the image to display.
Both $random_1 and $file_1 contain the correct information and the values for both display fine. But, I can't seem to use them to display the images.
My thinking is to do something like this within the <?php ?>
General random #1.
Create file name #1.
Display image #1.
Generate random #2.
Create file name #2.
Display image #2.
etc.
Ideally, I would like to use the images side by side as my page header so there may need to be divs or spans to format each image so I'm thinking that the images have to be displayed from within the php code.
I have been all over the web and nothing seems to work. I don't know if there's something special I need to do because it's WordPress, the image display code is wrong or I can't build a file name the way I am.
Any help would be greatly appreciated.
After spending way too long messing with it, I thought maybe I could do my own thing and come up with exactly what I wanted instead of making something else work.
I think I may have stumbled onto a really slick way to generate the random numbers except my efforts lead to no image being displayed either. lol
So, here's what I've got...
A sub-directory in my theme's directory called random-image. In it are files named 1.jpg, 2.jpg, 3.jpg etc.
I'm getting a random number ($random_1).
I had hoped I could add on the directory and .jpg extension when making the image display. That didn't seem to work so I created another variable $file_1 and took the random number and added ".jpg" to it. Again, no luck on getting the image to display.
Both $random_1 and $file_1 contain the correct information and the values for both display fine. But, I can't seem to use them to display the images.
My thinking is to do something like this within the <?php ?>
General random #1.
Create file name #1.
Display image #1.
Generate random #2.
Create file name #2.
Display image #2.
etc.
Ideally, I would like to use the images side by side as my page header so there may need to be divs or spans to format each image so I'm thinking that the images have to be displayed from within the php code.
I have been all over the web and nothing seems to work. I don't know if there's something special I need to do because it's WordPress, the image display code is wrong or I can't build a file name the way I am.
Any help would be greatly appreciated.