Location Address Display

This topic contains 22 replies, has 8 voices, and was last updated by  ssalustri 8 years, 10 months ago.

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

Open Support Ticket
  • Author
    Posts
  • #62940

    insurguru15
    Buyer
    Post count: 15

    How do I go about changing how the address displays?

    This is how it displays now:

    5700 S Cicero Ave
    Chicago
    Illinois
    60638
    United States

    This is how I want it to display:

    5700 S Cicero Ave,
    Chicago, Illinois 60638
    United States

    I’m using the GDF Modern Theme with the GeoDirectory_Framework theme compatibility pack.

    Thank You

    #62970

    Paolo
    Site Admin
    Post count: 31206

    Hi,

    you asked the same exact thing a couple of months ago, am I missing something? https://wpgeodirectory.com/support/topic/style-listing-box-on-homepage-and-map/

    Let us know,

    Thanks

    #63004

    insurguru15
    Buyer
    Post count: 15

    I couldn’t get the code to work but I just figured it out.

    Thanks

    #63051

    Paolo
    Site Admin
    Post count: 31206

    You are welcome 🙂

    #63152

    Joy
    Buyer
    Post count: 1076

    Can you share what you did to fix this? I can’t access that particular forum.

    #63272

    Paolo
    Site Admin
    Post count: 31206

    He wrote :

    I found this code and it worked great. How would I add commas after the city and state?

    
    
    add_filter('geodir_show_post_address', 'geodir_change_address_order' , 100 , 2) ;
    function geodir_change_address_order($html , $vars)
    {
    	global $post, $preview, $wpdb;
    	$field_icon='';
    	if (strpos($field_icon,'http') !== false) {$field_icon_af = '';}
    		elseif($field_icon==''){$field_icon_af = '<i class="fa fa-home"></i>';}
    		else{$field_icon_af = $field_icon; $field_icon='';}
    	
    	if(!$preview)
    	{
    		$html = '<p class="" style="clear:both;" itemprop="address" itemscope itemtype="http://schema.org/PostalAddress">';
    		$html .= '<span class="geodir-i-location" style="'.$field_icon.'">'.$field_icon_af;
    		$html .=  '&nbsp;';
    		$html .= '</span>';
    		//print_r($_POST);
    		
    		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>&nbsp;';}
    		if($post->post_region){ $html .= '<span itemprop="addressRegion">'.$post->post_region.'</span>&nbsp;';}
    		if($post->post_zip){ $html .= '<span itemprop="postalCode">'.$post->post_zip.'</span><br>';}
    		if($post->post_country){ $html .= '<span itemprop="addressCountry">'.$post->post_country.'</span><br>';}
    		$html .= '</p>';
    	}
    	return $html ;
    }

    I replied:

    you need to put it after :

    '.$post->post_city.'

    Example:

    if($post->post_city){ $html .= '<span itemprop="addressLocality">'.$post->post_city.',</span>&nbsp;';}

    Thanks

    #63343

    Joy
    Buyer
    Post count: 1076

    Thank you very much, this works well. However, it also removed the ‘Address’ label. How can I add that back in? Thank you.

    #63344

    Joy
    Buyer
    Post count: 1076

    LOL, I figured it out. If anyone else is interested in adjusting the address layout, here’s the code, place in your child theme function.php file:

    
    
    add_filter('geodir_show_post_address', 'geodir_change_address_order' , 100 , 2) ;
    function geodir_change_address_order($html , $vars)
    {
    	global $post, $preview, $wpdb;
    	$field_icon='';
    	if (strpos($field_icon,'http') !== false) {$field_icon_af = '';}
    		elseif($field_icon==''){$field_icon_af = '<i class="fa fa-home"></i>';}
    		else{$field_icon_af = $field_icon; $field_icon='';}
    	
    	if(!$preview)
    	{
    		$html = '<p class="" style="clear:both;" itemprop="address" itemscope itemtype="http://schema.org/PostalAddress">';
    		$html .= '<span class="geodir-i-location" style="'.$field_icon.'">'.$field_icon_af;
    		$html .=  '&nbsp;';
    		$html .= '</span>';
    		//print_r($_POST);
    		
    		if($post->post_address){ $html .= 'Address:<br><span itemprop="streetAddress">'.$post->post_address.'</span><br>';}
    		if($post->post_city){ $html .= '<span itemprop="addressLocality">'.$post->post_city.', </span>&nbsp;';}
    		if($post->post_region){ $html .= '<span itemprop="addressRegion">'.$post->post_region.'</span>&nbsp;';}
    		if($post->post_zip){ $html .= '<span itemprop="postalCode">'.$post->post_zip.'</span><br>';}
    		if($post->post_country){ $html .= '<span itemprop="addressCountry">'.$post->post_country.'</span><br>';}
    		$html .= '</p>';
    	}
    	return $html ;
    }
    #63401

    Paolo
    Site Admin
    Post count: 31206

    Thanks for sharing 🙂

    #65219

    recoveryweb247
    Free User
    Post count: 8

    This code does not work for me can someone please help. I am using the Multi News Theme

    #65254

    Paolo
    Site Admin
    Post count: 31206

    Hi,

    I just double checked and the code is correct. Where are you adding it?

    Please provide a link and admin credentials in a private reply and we will have a look.

    Thanks

    #65829

    recoveryweb247
    Free User
    Post count: 8
    This reply has been marked as private.
    #65980

    recoveryweb247
    Free User
    Post count: 8
    This reply has been marked as private.
    #66429

    diningout
    Free User
    Post count: 1

    Thanks 🙂

    #112621

    chrisat15
    Expired Member
    Post count: 67

    Thanks for sharing!

    If anyone is interested in austrian or german style, feel free to use this code:

    
    
    // Formatting address in GD sidebar
    add_filter('geodir_show_post_address', 'geodir_change_address_order' , 100 , 2) ;
    function geodir_change_address_order($html , $vars)
    {
    	global $post, $preview, $wpdb;
    	$field_icon='';
    	if (strpos($field_icon,'http') !== false) {$field_icon_af = '';}
    		elseif($field_icon==''){$field_icon_af = '<i class="fa fa-home"></i>';}
    		else{$field_icon_af = $field_icon; $field_icon='';}
    	
    	if(!$preview)
    	{
    		$html = '<p class="" style="clear:both;" itemprop="address" itemscope itemtype="http://schema.org/PostalAddress">';
    		$html .= '<span class="geodir-i-location" style="'.$field_icon.'">'.$field_icon_af;
    		$html .=  '&nbsp;';
    		$html .= '</span>';
    		//print_r($_POST);
    		
    		if($post->post_address){ $html .= 'Address:<br><span itemprop="streetAddress">'.$post->post_address.'</span><br />';}
    		if($post->post_zip){ $html .= '<span itemprop="postalCode">'.$post->post_zip.'</span>&nbsp;';}
    		if($post->post_city){ $html .= '<span itemprop="addressLocality">'.$post->post_city.'</span><br />';}
    		if($post->post_region){ $html .= '<span itemprop="addressRegion">'.$post->post_region.', </span>&nbsp;';}
    		if($post->post_country){ $html .= '<span itemprop="addressCountry">'.$post->post_country.'</span><br>';}
    		$html .= '</p>';
    	}
    	return $html ;
    }
Viewing 15 posts - 1 through 15 (of 23 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