How to get Address value

This topic contains 17 replies, has 3 voices, and was last updated by  Paolo 9 years, 8 months ago.

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket
  • Author
    Posts
  • #35631

    sleepydada
    Free User
    Post count: 12

    Hi,

    I’m trying to create a search form that has multiple fields, including one for searching by location. I’m trying to figure out how to get the address value from each listing, but nothing seems to be working. This is what I have:

    <?php echo geodir_post_custom_fields($post->id, ‘address’, true); ?>

    which simply displays:

    Array Array Array Array Array Array Array Array Array Array

    I’d appreciate your help.

    Thanks.

    #35634

    Simone
    Expired Member
    Post count: 3515

    Hello the correct is

    
    
    <?php echo geodir_get_post_meta($post->id,'post_address',true);  ?>
    
    #35635

    sleepydada
    Free User
    Post count: 12

    Thanks so much for your quick response! But it’s still showing “Array Array …”

    #35637

    sleepydada
    Free User
    Post count: 12

    No I mean, now the page does not display anything

    #35638

    sleepydada
    Free User
    Post count: 12

    This is the whole code:

    
    
    <?php
    /* Template Name: Search Test */
    ?>
    <?php get_header();?>
    
          <?php
            global $wp_query;
            query_posts(array(
                'post_type' => 'gd_place'
            ));
    
            while(have_posts()) : the_post(); ?>
                
    
    <?php echo geodir_get_post_meta($post->id,'post_address',true);  ?>
                
             <?php
            endwhile;
            wp_reset_query();
            ?>
    
    <?php get_footer();
    
    #35639

    Simone
    Expired Member
    Post count: 3515

    try to set the ID in a different variable such as

    $postid = $wp_query->post->ID; // retrieve the ID

    and then use it like this

    
    
    $address= geodir_get_post_meta($postid,'post_address',true); 
    echo $address;
    #35641

    sleepydada
    Free User
    Post count: 12

    That works! Thank you!

    #35642

    Simone
    Expired Member
    Post count: 3515

    glad it works, you’re welcome

    #35653

    sleepydada
    Free User
    Post count: 12

    Now… How could I query this??

    #35654

    Simone
    Expired Member
    Post count: 3515

    ..what you mean?

    #35655

    sleepydada
    Free User
    Post count: 12

    I think I need to query this to search through it, but not sure how to do it…!

    #35656

    Simone
    Expired Member
    Post count: 3515

    Hmm not sure what you are trying to do here 🙂 A search for ..what keywords?

    #35657

    sleepydada
    Free User
    Post count: 12

    I’m trying to build a search form with multiple fields, and one of them is location field. You can search the location either by address or zip code.

    #35658

    Simone
    Expired Member
    Post count: 3515

    why can’t you use the gd search form with the advanced fields? you can also use the shortcode so you can use it where you want

    #35660

    sleepydada
    Free User
    Post count: 12

    First it’s not working — I click on the submit button but it doesn’t do anything — and also I need to combine other optioned to the search form.

Viewing 15 posts - 1 through 15 (of 18 total)

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket
20% Discount Offer
Hurry! Get your 20% discount before it expires. Get 20% Discount