Try the following code: (I’ve not tested it, so there might be few things here and there, but you can get the overall idea):
add_shortcode('boats', 'shortcode_boats');
function shortcode_boats($atts){
//merge the passed attributes with defaults
extract(
shortcode_atts(
array(
'post_type' => 'yacht-for-sale',
'post_status' => 'publish',
'posts_per_page' => 15,
'caller_get_posts' => 1 //i am not sure what you are doing with this value
),
$atts
)
);
//now create a seprate agruments array for wp_query using the values from above(extracted variables)
$args = array(
'post_type' => $post_type,
'post_status' => $post_status,
'posts_per_page' => $posts_per_page
);
ob_start();
$my_query = new WP_Query( $args );
if( $my_query->have_posts() ) {
?>
<h3>List of Available Yachts & Catamarans</h3>
<div id="boatlist">
<?php
while ($my_query->have_posts()) : $my_query->the_post();
$price = get_post_meta( get_the_ID(), 'price', true); ?>
<p class="boatrow">
<span class="s-left"><?php the_title(); ?></span>
<?php if( isset( $price ) ) : ?>
<span class="s-right"><?php echo $price; ?></span>
<?php endif;?>
</p>
<?php endwhile; ?>
</div>
<?php
}
wp_reset_query();//reset the global variable related to post loop
$retVal = ob_get_contents();
ob_end_clean();
return $retVal;
}