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 TicketTagged: address, css, GDF Modern Theme, location
-
AuthorPosts
-
December 8, 2015 at 3:50 pm #62940
How do I go about changing how the address displays?
This is how it displays now:
5700 S Cicero Ave
Chicago
Illinois
60638
United StatesThis is how I want it to display:
5700 S Cicero Ave,
Chicago, Illinois 60638
United StatesI’m using the GDF Modern Theme with the GeoDirectory_Framework theme compatibility pack.
Thank You
December 8, 2015 at 8:07 pm #62970Hi,
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
December 9, 2015 at 2:21 am #63004I couldn’t get the code to work but I just figured it out.
Thanks
December 9, 2015 at 4:15 pm #63051You are welcome 🙂
December 10, 2015 at 1:00 am #63152Can you share what you did to fix this? I can’t access that particular forum.
December 10, 2015 at 9:05 pm #63272He 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 .= ' '; $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> ';} if($post->post_region){ $html .= '<span itemprop="addressRegion">'.$post->post_region.'</span> ';} 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> ';}
Thanks
December 11, 2015 at 9:18 am #63343Thank you very much, this works well. However, it also removed the ‘Address’ label. How can I add that back in? Thank you.
December 11, 2015 at 9:21 am #63344LOL, 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 .= ' '; $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> ';} if($post->post_region){ $html .= '<span itemprop="addressRegion">'.$post->post_region.'</span> ';} 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 ; }
December 11, 2015 at 4:52 pm #63401Thanks for sharing 🙂
December 24, 2015 at 9:19 am #65219This code does not work for me can someone please help. I am using the Multi News Theme
December 24, 2015 at 5:36 pm #65254Hi,
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
December 30, 2015 at 11:20 am #65829This reply has been marked as private.December 30, 2015 at 9:07 pm #65980This reply has been marked as private.January 3, 2016 at 11:32 pm #66429Thanks 🙂
January 27, 2016 at 10:07 pm #112621Thanks 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 .= ' '; $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> ';} 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> ';} if($post->post_country){ $html .= '<span itemprop="addressCountry">'.$post->post_country.'</span><br>';} $html .= '</p>'; } return $html ; }
-
AuthorPosts
We have moved to a support ticketing system and our forums are now closed.
Open Support Ticket