While loop in custom shortcode only shows one record

I am trying to run a while loop inside a custom shortcake but it is only showing 1 record even though I know there are more.

function my_shortcode() {

$args = array(
‘post_type’ => ‘properties’,
‘posts_per_page’ => 6
);
$properties = new WP_Query($args);

while ($properties->have_posts() ): $properties->the_post();
$card_img = get_field( ‘card_image’ );

$output = ‘<div class=”prop-container”>’.
‘<div class=”property”>’.
‘<img src=”‘. $card_img[‘url’] .'”>’.
‘</div>’.
‘</div>’;
endwhile;
wp_reset_postdata();
return $output;

}
add_shortcode( ‘properties’, ‘my_shortcode’ );

Read more here:: While loop in custom shortcode only shows one record

Leave a Reply

Your email address will not be published. Required fields are marked *