10-13-2010, 07:24 PM
| THREAD STARTER
#1 (permalink)
|
| NamePros Regular Join Date: Jul 2004 Location: USA
Posts: 555
| How to display a random image in this code? Hope one of you PHP gurus can help me ...
In a WordPress theme, I want to change this code: 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/default_thumbnail.png', 'width' => '100', 'image_class' => 'wp-post-image' )); } ?> to something like ????: NamePros.com http://www.namepros.com/programming/682041-how-to-display-random-image-code.html 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/default_thumbnail_0<?php echo rand(1,3)?>.png', 'width' => '100', 'image_class' => 'wp-post-image' )); } ?> 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? |
| |