0

ループでget_post_customを呼び出すと、正しく機能します。しかし、それは私の画面に38を印刷します。それはwpバグですか、それとも何ですか?どうすれば修正できますか?

詳細:get_post_metaを呼び出すと発生します。カスタムフィールドテンプレートプラグインを使用しています。

$args = array(
        'post_type' => 'attendeeaddress',
        'meta_query' => array(
            array(
                'key' => 'MEETING_ID',
                'value' => $meeting_id,
                'meta_compare' => '='
            )
        )
    );
    $wpquery = new WP_Query($args);
    $addresses = array();
    while ( $wpquery->have_posts() ) : $wpquery->the_post();
        $custom_val = get_post_custom(the_ID());
        $addresses[] = array(
            "address" => $custom_val["MEETING_ADDRESS"][0],
            "meeting_id" => $meeting_id,
            "lat" => $custom_val["MEETING_LAT"][0],
            "lon" => $custom_val["MEETING_LON"][0],
            "name" => $custom_val["NAME"][0]
        );
    endwhile;

    return $addresses;
4

1 に答える 1

3

これは、the_ID();が原因です。実際に値を「エコー」します。

値を収集するには、get_the_ID() ;を使用します。

http://codex.wordpress.org/Function_Reference/the_ID http://codex.wordpress.org/Function_Reference/get_the_ID

  • これはループでのみ使用する必要があります。
于 2012-04-10T07:01:21.277 に答える