get_post_meta不适用于变量

时间:2015-02-12 06:50:50

标签: wordpress loops custom-fields

$ event_count变量不会打印任何内容,我做错了什么?

global $post;
$event_count = get_post_meta($post->ID, 'eab_event-bp-group_event', true);

$args = array(
    'post_type' => 'incsub_event',
    'posts_per_page' => -1,
    'meta_key' => 'eab_event-bp-group_event',
    'order' => 'ASC',
    'meta_query' => array(
            array(
                'key'     => 'eab_event-bp-group_event',
                'value'   => $event_count,
            ),
        ),
);

$my_query = new WP_Query( $args );

if ( $my_query->have_posts() ) {
    echo '<ul>';
    while ( $my_query->have_posts() ) {
        $my_query->the_post();
        echo '<li>' . get_the_title() . '</li>';
    }
    echo '</ul>';
} else {

}
wp_reset_postdata();`

0 个答案:

没有答案