Wordpress PHP自定义字段 - 幻灯片显示的单个链接

The following is code for a Wordpress slideshow. The images are added through custom fields. I would like to be able to add a different link (or no link) to each of the slides. The current code is below, any tips on how to do that? The theme is quite old.

Thank you!!

<?php
        /* reading the custom field value 'headerImage'
            * muliple 'headerImage' image will cause js transition
            * if no 'headerImage' found then 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 to add another custom field for the link of each image , where you are insering the header image in post_meta you need to add the custom field say, img_link also , then you can do it this 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;


    ?>