Hope one of you PHP gurus can help me ... In a WordPress theme, I want to change this code: <?php if ( function_exists( 'get_the_image' ) ) { get_the_image(array( 'default_size' => 'thumbnail', 'image_scan' => true, 'default_image' => get_bloginfo( 'template_url' ) . '/images/[color=#FF0000]default_thumbnail.png[/color]', 'width' => '100', 'image_class' => 'wp-post-image' )); } ?> Code (markup): to something like <?php if ( function_exists( 'get_the_image' ) ) { get_the_image(array( 'default_size' => 'thumbnail', 'image_scan' => true, 'default_image' => get_bloginfo( 'template_url' ) . '/images/[color=#FF0000]default_thumbnail_0<?php echo rand(1,3)?>.png[/color]', 'width' => '100', 'image_class' => 'wp-post-image' )); } ?> Code (markup): so a random image between 1 and 3 is displayed as thumbnail. But my code doesn't work ... no image is displayed Any idea how I should change it?
Are these files exist? /images/default_thumbnail_01.png , /images/default_thumbnail_02.png , /images/default_thumbnail_03.png
<?php if ( function_exists( 'get_the_image' ) ) { get_the_image(array( 'default_size' => 'thumbnail', 'image_scan' => true, 'default_image' => get_bloginfo( 'template_url' ) . '/images/default_thumbnail_0' . rand(1,3) . '.png', 'width' => '100', 'image_class' => 'wp-post-image' )); } ?> PHP: Still doesn't work ?
<?php //set the number you want to randomize between first. $randomize = rand(1, 3); //check and display the random image now if ( function_exists( 'get_the_image' ) ) { get_the_image(array( 'default_size' => 'thumbnail', 'image_scan' => true, 'default_image' => get_bloginfo( 'template_url' ) . '/images/default_thumbnail_0' . $randomize . '.png', 'width' => '100', 'image_class' => 'wp-post-image' )); } ?> PHP:
@sunlcik Yes, they do. @ActiveFrost That did the trick, thanks! (Added to your rep) @lowridertj That also works (got a similar solution on another forum), but I like ActiveFrost's solution for its simplicity. Thanks anyway. Thanks guys, problem solved.
one another method all image store in the database and use select random order query and show in the front and for animation you will use java script.