i would like to create a shortcode which will display a loop for CPT = testimonials. I've prepared such code:
function testimonials_loop_shortcode() {
$args = array(
'post_type' => 'testimonials',
'post_status' => 'publish',
);
$my_query = null;
$my_query = new WP_query($args);
while ($my_query->have_posts()) : $my_query->the_post();
$custom = get_post_custom( get_the_ID() );
?><p><?php the_title();?></p><?php
?><p>the_content();</p><?php
wp_reset_postdata();
else :
_e( 'Sorry, no posts matched your criteria.' );
endif;
}
add_shortcode( 'testimonials_loop', 'testimonials_loop_shortcode' );
It's prepared to be pasted inside functions.php. But the code breaks the website / error 500. what im doing wrong?