• Hi all

    well, i ha a cutom field called “background” where i inser images to display as background image. So far thats no problem. i an insert a image in that field in every page to show different background images.

    now i want do show a random background image on startpage, or pages without a specific background-image, so i need 1st a if else, and then a random image from that custom field.

    any idea for me???

    her my code so far:

    <?php ?>
    <?php $image = get_post_meta($post->ID, 'background', true); ?>
    <?php if (get_post_meta($post->ID, 'background', true) ) { ?>
    
    <img src="<?php bloginfo('url'); ?>/wp-content/uploads/<?php echo $image; ?>" alt="<?php the_title(); ?>" title="<?php the_title(); ?>" />
    
    <?php } else { ?>
    
    HERE I NEED YOUR HELP!
    i should show a random background image from that custom field.
    
    <?php } ?>

    Thank you very much!

  • The topic ‘Custom Field Background Image – Random’ is closed to new replies.