0

我的问题是我使用简码来显示自定义帖子的内容,一切正常,除了当我在文章中使用此简码时,分页显示其他自定义实体,而不是显示其他文章。

这是我的代码:

function tour_dates($concert_date) {
extract(shortcode_atts(array(
    'date' => '2013-08-22'
), $concert_date));

$cp_query = new WP_Query( array('post_type' => 'concerts', 'posts_per_page' => -1, 'meta_key' => 'tourdate', 'meta_value' => $concert_date['date']) );
if( $cp_query->have_posts() ) {
    while ($cp_query->have_posts()) {
        setup_postdata($cp_query->the_post());
        $id = get_the_ID();
        $custom = get_post_meta($id);
        return 'Les informations du concert : ' . $custom['tourdate'][0] . ' @ ' . $custom['tourcity'][0];
    }
}
else {
    echo 'No concert found on ' . $concert_date['date'];
}
wp_reset_query();

}
add_shortcode('concert', 'tour_dates');

我不明白为什么这会显示其他自定义条目...

谢谢

4

0 回答 0