format listing detail address

This topic contains 6 replies, has 4 voices, and was last updated by  Joshua Dobbs 6 years, 3 months ago.

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

Open Support Ticket
  • Author
    Posts
  • #412143

    Joshua Dobbs
    Expired Member
    Post count: 90

    I followed this post https://wpgeodirectory.com/docs/changing-the-layout-of-addresses/ and am trying to change the format of the address to this:

    Adresse:
    <Street> <Streetnumber>
    <Zip> <City>
    Kanton <Sankt Gallen>

    I added the following code to snippets and activated it but i’m not seeing any changes.

    
    
    		if($post->post_address){ 
    			$html .= '<span itemprop="streetAddress">'.$post->post_address.'</span>';
    		}
    		if($post->post_zip){
    		   $html .= '<span itemprop="postalCode">'.$post->post_zip.'</span>,';
    		}
    
    		if($post->post_city){ 
    			 $html .= '<span itemprop="addressLocality">'.$post->post_city.'</span> ';
    		}
    		if($post->post_country){ 
    			$html .= '<span itemprop="addressCountry">'.$post->post_country.'</span>';
    		}
    		if($post->post_region){
    			$html .= 'Kanton <Sankt Gallen>';
    		}

    am I doing something wrong?

    #412160

    Kor
    Moderator
    Post count: 16516

    Hi Joshua,

    How do you want it to look like? Could you provide an example? Also, please share WP admin access in private reply here so that we could test the code directly.

    Thanks!

    #412169

    Guust
    Moderator
    Post count: 29970

    You missed a lot of the code out. The second part of the code is just showing a customized part only, you still need to include the beginning and the end of the code shown in the beginning of the article.

    Thanks

    #412192

    Joshua Dobbs
    Expired Member
    Post count: 90

    doh! thanks Guust. ill try that again.

    #412195

    Joshua Dobbs
    Expired Member
    Post count: 90
    This reply has been marked as private.
    #412199

    Alex Rollin
    Moderator
    Post count: 27815

    Hello @joshdobbs,

    I used this snippet on my test site and it comes out looking like the attached image:

    
    
    
    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 = '
    
    ';
    		$html .= '<span class="geodir-i-location" style="'.$field_icon.'">'.$field_icon_af;
    		$html .=  '&nbsp;Adresse:&nbsp;';
    		$html .= '</span>';
    		//print_r($_POST);
    		
    		if($post->post_address){ $html .= '<span itemprop="streetAddress">'.$post->post_address.'</span>
     ';}
    	  		if($post->post_zip){ $html .= '<span itemprop="postalCode">'.$post->post_zip.'</span>
     ';}
    		if($post->post_city){ $html .= '<span itemprop="addressLocality">'.$post->post_city.'</span>
     ';}
    		if($post->post_region){ $html .= '<span itemprop="addressRegion">'.$post->post_region.'</span>
     ';}		
    
    		$html .= '
    
    ';
    	}
    	return $html ;
    }
    
    
    #412213

    Joshua Dobbs
    Expired Member
    Post count: 90

    Thanks. I see the issue now. I think there is a conflict with another function of the same name.

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

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

Open Support Ticket