1
我想创建一个短代码,它将显示CPT =感言的循环。我准备了这样的代码:短代码内的Wordpress自定义文章类型循环
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');
它准备粘贴在functions.php中。但代码打破了网站/错误500.我做错了什么?