<div id="slider" class="nivoSlider">
<?php
query_posts("post_type=slider&post_status=publish&posts_per_page=6");
while ( have_posts() ) : the_post();
?>
<?php
$custom = get_post_custom($post->ID);
$url = get_post_custom_values("slider-url");
$sl_thumb = $custom["thumb"][0];
$sl_caption = $custom["caption"][0];
$sl_htmlcaption = $custom["htmlcaption"][0];
?>
<?php if(has_post_thumbnail( $the_ID) || $sl_thumb!=""){ ?>
<?php
if($sl_thumb!=""){
echo "<a href='" . $url[0] . "'>";
echo "<img src='" . $sl_thumb . "' alt='' title='#" . $sl_caption . "' />";
echo "</a>";
} else{
echo "<a href='" . $url[0] . "'>";
the_post_thumbnail( 'slider-post-thumbnail' );
echo "</a>";
}
?>
<?php } ?>
<?php endwhile; ?>
<?php wp_reset_query();?>
</div>
<?php
query_posts("post_type=slider&post_status=publish");
while ( have_posts() ) : the_post();
?>
<?php
$custom = get_post_custom($post->ID);
$sl_caption = $custom["caption"][0];
$sl_htmlcaption = $custom["htmlcaption"][0];
?>
<?php
echo "<div id='" . $sl_caption . "' class='nivo-html-caption'>" . $sl_htmlcaption . "</div>";
?>
<?php endwhile; ?>
<?php wp_reset_query();?>
<a href="<?php bloginfo('url'); ?>/?page_id=72" class="button slider-button">View More</a>