Support » Plugin: WPCasa » REST API WP CASA

  • Resolved heneart

    (@heneart)


    Hi,
    thanx for the nice plugin.
    I’m trying to get specific metas from WP Casa , and store in json file.
    So far I get the file stored, but I’m really stuck with the question, how to get the WP Casa post type metas….

    my funcion is:
    ————————————–
    $args = array(
    ‘post_type’ => ‘listing’,
    ‘post_status’ => ‘publish’,
    ‘posts_per_page’ => -1,
    );

    $query = new WP_Query( $args );
    $posts = array();

    while( $query->have_posts() ) : $query->the_post();

    $posts[] = array(
    ‘title’ => get_the_title(),
    ‘excerpt’ => get_the_excerpt(),
    ‘author’ => get_the_author(),
    ‘link’ => get_permalink(),
    ‘listing-ID’ => get_post_meta( $post->ID, ‘_listing_id’, true ),
    ‘listing price’ => get_post_meta( $post->ID, ‘_price’, true ),
    );

    endwhile;

    wp_reset_query();
    ———————-

    the last two lines listing-ID and listing price doesn’t work, showing “false” in json file. I think, the problem is with $post->ID in get_post_meta, cause setting directly the id, f.ex. 23, everything works fine.

    Maybe someone has an idea?
    Thanx

Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.