adjusting address format and adding directions button

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

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

Open Support Ticket
  • Author
    Posts
  • #34280

    BL Interactive
    Expired Member
    Post count: 83

    I wanted to make the address be only 2 lines and I also wanted a get directions button that opens a new window in google maps.

    I modified custom_fields_functions.php lines 1868-1776 as seen bellow.

    It works great, but my question is how can I do this in a way that is not obliterated on update?

    Additionally, is there a way to use the 2 letter state code (WI fir Wisconsin and so on)?

    
    
    if($preview){	$html .= stripslashes($post->$html_var).$addition_fields.'</p>' ;}
    else{
    	if($post->post_address){ $html .= '<span itemprop="streetAddress">'.$post->post_address.'</span><br>';}
    	if($post->post_city){ $html .= '<span itemprop="addressLocality">'.$post->post_city.'</span>, ';}
    	if($post->post_region){ $html .= '<span itemprop="addressRegion">'.$post->post_region.'</span> ';}
    	if($post->post_zip){ $html .= '<span itemprop="postalCode">'.$post->post_zip.'<br><br></span> ';}
    	if($post->post_address){ $html .= '<a href="https://www.google.com/maps/place/'.$post->post_address.' '.$post->post_city.' '.$post->post_zip.'" target="_blank" class="geodir_dirbtn"><i class="fa fa-car" style="padding-right:10px"></i> Directions</a>';}
    	$html .= '</div>';
    }
    #34311

    Paolo
    Site Admin
    Post count: 31206

    Hi,

    for the 1st question, currently the only way to modify that function and keep it update proof, would be to create a small plugin with that function alone inside, that must be loaded before GeoDirectory.

    I’ve asked Stiofan to look into your question and see if there is an easier way though.

    It is not possible to use 2 letters code, because we take those from Google Maps API and they return the full name.

    Thanks

    #34325

    BL Interactive
    Expired Member
    Post count: 83

    Is there a doc on creating the plugin? Would I replace the entire function geodir_show_listing_info?

    I tried fooling with my themes function.php but couldn’t get anything to work.

    #34332

    Paolo
    Site Admin
    Post count: 31206

    hi,

    you can see here documentation on how to create a wordpress plugin: http://codex.wordpress.org/Writing_a_Plugin

    Normally plugins are loaded in alphabetical order based on the directory name, make sure your plugin is loaded before GeoDirectory.

    Yes you would replace the entire function, it is pluggable.

    The plugins in wordpress are loaded right before theme, so tweaking it in functions doesn’t do anything.

    Thanks

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

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

Open Support Ticket