Getting Current Location's Country?

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

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

Open Support Ticket
  • Author
    Posts
  • #18882

    Greg McEwan Marriott
    Buyer
    Post count: 36

    Hi, You guys have already helped me (thank you) managing to use the geodir_get_current_location function to return the current location as in city… is there an easy way to get City, Country? Does the geodir_get_current_location array contain anything else than the city name?

    #18896

    Simone
    Expired Member
    Post count: 3515

    Hello, I created this function to obtain the value you are looking for (and place it in the detail page), if you read it, it is easily understandable and you can use it whenever you want

    
    
    add_action( 'geodir_after_listing_post_title', 'country_listing', 45 );
    function country_listing() {
    global $post;
    global $wp_query;
    
    $postid = $wp_query->post->ID;
    $postcity= geodir_get_post_meta($postid,'post_city',true); 
    $postregion= geodir_get_post_meta($postid,'post_region',true); 
    $postcountry= geodir_get_post_meta($postid,'post_country',true); 
    
    echo $postcountry." - ".$postregion." - ".$postcity;
    
    }
    
    #18949

    Paolo
    Site Admin
    Post count: 31206

    The code I gave you the other day should work for all locations, not only cities.

    Thx

Viewing 3 posts - 1 through 3 (of 3 total)

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

Open Support Ticket