Wordpress PHP custom field - Individual links for slideshow -
Wordpress PHP custom field - Individual links for slideshow -
the next code wordpress slideshow. images added through custom fields. able add together different link (or no link) each of slides. current code below, tips on how that? theme quite old.
thank you!!
<?php /* reading custom field value 'headerimage' * muliple 'headerimage' image cause js transition * if no 'headerimage' found display default-header.jpg */ $headerimages = get_post_meta($post->id, "headerimage", false); ?> <!--photo starts--> <div class="photo noprint"> <div id="fx" class="big-image"> <?php if( is_array( $headerimages ) && count( $headerimages ) > 0 ): for( $i=0; $i<count($headerimages); $i++ ): ?> <img src="<?php echo $headerimages[$i]; ?>" alt=""<?php if($i != 0) echo ' style="display:none;"'; ?> /> <?php endfor; else: ?> <img src="<?php bloginfo('template_url'); ?>/images/default-header.jpg" alt="" /> <?php endif; ?> </div> </div>
you need add together custom field link of each image , insering header image in post_meta need add together custom field say, img_link , can way .
<?php $headerimages = get_post_meta($post->id, "headerimage", false); $img_link = get_post_meta($post->id, "img_link", false); if( is_array( $headerimages ) && count( $headerimages ) > 0 && is_array( $img_link ) && count( $img_link ) > 0 ): for( $i=0; $i < count($headerimages) , $i < count ($img_link ) ; $i++ ): ?> <a href = "<?php echo $img_link[$i]; ?>" > <img src="<?php echo $headerimages[$i]; ?>" alt=""<?php if($i != 0) echo ' style="display:none;"'; ?> /> </a> <?php endfor; else: ?> <img src="<?php bloginfo('template_url'); ?>/images/default-header.jpg" alt="" /> <?php endif; ?> php wordpress custom-fields
Comments
Post a Comment