Hi there,
I am generally new to PHP and Wordpress, but I went through a long winded Wordpress tutorial and I am fairly comfortable working with it now. I am a Java programmer but not really a PHP programmer but if you know one language its not far from the others.
Anyways, on to the question at hand. I would like to have each post have a different background image. Essentially I would like to have it cycle through 3 images. First post would have image 1, second post would have image 2, third post would have image 3, the fourth post would have image 1 again. Anyways How would I have the program call each image?
Would you like some of my wordpress code to help you?
Wordpress Post Images
Moderator: General Moderators
Re: Wordpress Post Images
here's a java code and convert it to php
Code: Select all
String[] images = new String[3];
images[0] = "Image1.JPEG";
images[1] = "Image2.JPEG";
images[3] = "Image3.JPEG";
// assuming the posts are arranged in an array(because it would be quite complicated using database connection strings in java and post it here)
String[] posts = new String[4];
posts[0] = "This is Post 1";
posts[1] = "This is Post 2";
posts[2] = "This is Post 3";
posts[3] = "This is Post 4";
// then we display the posts with background
int j = 0;
for(int i = 0; i < posts.length; i++)
{
// we set the background of the post using images[j]
//.....
//.....
// then we display the post using posts[i]
//.....
//.....
if(j < images.length)
{
j++;
}
else
{
j=0;
}
}