Show complete address

This topic contains 24 replies, has 4 voices, and was last updated by  Giri 4 years, 5 months ago.

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

Open Support Ticket
  • Author
    Posts
  • #381643

    Tania Perez
    Full Member
    Post count: 299

    Hello!

    Is it possible to show the complete address of the CPT, right under the title of the listing, instead of only showing the country, and region?

    I´d like it to show street, and neighborhood too.

    Thank you!

    #381649

    Kor
    Moderator
    Post count: 16516

    Hi Tania,

    Please try using the custom CSS code below and see if it works. Insert into the “Code Snippets” plugin.

    
    
    function gd_custom_sd_details_output_address( $address = '' ) {
        global $post;
        
        if ( $address && !empty( $post->post_address ) ) {
            $sd_address = '<span class="sd-address-only">' . stripslashes( $post->post_address  ) . ', </span>';
            $address = str_replace( '<div class="sd-address">', '<div class="sd-address">' . $sd_address , $address );
        }
        
        return $address;
    }
    add_filter( 'sd_details_output_address', 'gd_custom_sd_details_output_address', 10, 2 );
    #381806

    Tania Perez
    Full Member
    Post count: 299

    Hi Kor!

    It does show the street, but it doesn´t show the neighborhood. Can we add something else to it?

    It´s also creating a huge space between the address and the Description Fields. I´m attaching an image to show you.

    Can we fix that?

    Thank you!

    #381857

    Kor
    Moderator
    Post count: 16516

    Hi Tania,

    With the help from a developer, I’m able to fix the issue and added the neighbourhood to the address section. Could you check and see if it’s what you’re looking for? Below is the code for our reference.

    
    
    function gd_custom_sd_details_output_address( $address = '' ) {
        global $post;
        
        if ( $address && !empty( $post->post_address ) ) {
            $sd_address = '<span class="sd-address-only">' . stripslashes( $post->post_address  ) . ', </span>';
            $address = str_replace( '<div class="sd-address">', '<div class="sd-address">' . $sd_address , $address );
        }
        
        return $address;
    }
    add_filter( 'sd_details_output_address', 'gd_custom_sd_details_output_address', 10, 2 );
    
    function gd_custom_sd_details_output_social_neighbourhood( $social = '' ) {
        global $post;
        
        if ( geodir_is_page( 'detail' ) && !empty( $post ) && !empty( $post->post_neighbourhood ) && !empty( $post->country_slug ) && defined( 'GEODIRLOCATION_VERSION' ) ) {
            if ( get_option( 'location_neighbourhoods' ) && $neighbourhood_info = geodir_location_get_neighbourhood_by_id( $post->post_neighbourhood, true, $post->post_location_id ) ) {
                $social = '<div class="sd-neighbourhood" style="clear:both;"><span class="geodir-i-neighbourhood" style=""><i class="fa fa-location-arrow"></i> ' . __( 'Neighbourhood:', 'geodirectory' ) . ' </span> ' . $neighbourhood_info->hood_name . '</div>' . $social;
            }
        }
        
        return $social;
    }
    add_filter( 'sd_details_output_social', 'gd_custom_sd_details_output_social_neighbourhood', 10, 1 );
    #382412

    Tania Perez
    Full Member
    Post count: 299

    Thank you Kor!

    Almost:) The neighborhood is showing now, but below the rating, and not with the address.

    The right way would be: Street, Neighborhood, City, Region, Country.

    I´m attaching an image to show you how it should look (red frame is how it looks now, green how it should). The address can go in one single line, or two lines, like the example I´m sending.

    The huge space is now corrected!

    Thank you!

    #382423

    Kor
    Moderator
    Post count: 16516

    Hi Tania,

    Try using this custom CSS and see if it’s what you’re looking for.

    
    
    .sd-address font {
        display:block!important;
    }
    #382559

    Tania Perez
    Full Member
    Post count: 299

    Hi Kor!

    It didn´t do anything to the address bar.

    Let me attach the image again. The text in the yellow circle is the neighborhood, to be specific.

    Thank you!!!!

    #382972

    Giri
    Expired Member
    Post count: 3155

    Hi Tania,

    Try modifying kor code like this.

    Replace this line

    
    
    
    add_filter( 'sd_details_output_social', 'gd_custom_sd_details_output_social_neighbourhood', 10, 1 );

    with

    
    
    
    add_filter( 'sd_details_output_address', 'gd_custom_sd_details_output_social_neighbourhood', 11, 1 );
    #383285

    Tania Perez
    Full Member
    Post count: 299

    Hi Giri,

    It´s now showing the neighborhood on top of the address like this:
    Line 1: Neighborhood
    Line 2: Street, City, Region, Country.
    I´m attaching a screen of how it looks with the modification you sent.

    The way it should be is:
    Line 1: Street, Neighborhood,
    Line 2: City, Region, Country.

    Thank you!!

    Tania

    #383375

    Giri
    Expired Member
    Post count: 3155

    Hi Tania,

    remove existing code and replace with this one.

    
    
    function gd_custom_sd_details_output_address( $address = '' ) {
        global $post;
    
        $sd_address = '<div class="sd-address">';
        if (isset($post->post_city) && $post->post_city) {
            $sd_address .= apply_filters('sd_detail_city_name', $post->post_city, $post);
        }
        $sd_address .= '</div>';
        $sd_address .= '<div class="sd-address">';
        if ( geodir_is_page( 'detail' ) && !empty( $post ) && !empty( $post->post_neighbourhood ) && !empty( $post->country_slug ) && defined( 'GEODIRLOCATION_VERSION' ) ) {
            if ( get_option( 'location_neighbourhoods' ) && $neighbourhood_info = geodir_location_get_neighbourhood_by_id( $post->post_neighbourhood, true, $post->post_location_id ) ) {
                $sd_address .= '<div class="sd-neighbourhood" style="clear:both;"><span class="geodir-i-neighbourhood" style=""><i class="fa fa-location-arrow"></i> ' . __( 'Neighbourhood:', 'geodirectory' ) . ' </span> ' . $neighbourhood_info->hood_name . '</div>' . $social;
            }
        }
        $sd_address .= '</div>';
        $sd_address .= '<div class="sd-address">';
        if (isset($post->post_region) && $post->post_region) {
            $sd_address .= ', ' . apply_filters('sd_detail_region_name', $post->post_region, $post);
        }
        if (isset($post->post_country) && $post->post_country) {
            $sd_address .= ', ' . apply_filters('sd_detail_country_name', __($post->post_country, 'geodirectory'), $post);
        }
        $sd_address .= '</div>';
    
        return $sd_address;
    }
    add_filter( 'sd_details_output_address', 'gd_custom_sd_details_output_address', 10, 2 );
    #383652

    Tania Perez
    Full Member
    Post count: 299

    Hi Giri!!!

    I changed the code, but now it doesn´t show the streer, and now it´s showing this order, all in the same line:

    City, neighborhood, region, country

    Find an image attached

    Thanks for your help!!

    #383803

    Giri
    Expired Member
    Post count: 3155

    Hi Tania,

    Please try this code.

    
    
    function gd_custom_sd_details_output_address( $address = '' ) {
    	global $post;
    
    	$sd_address = '<div class="sd-address">';
    	if (isset($post->post_address) && $post->post_address) {
    		$sd_address .= apply_filters('sd_detail_post_add', $post->post_address, $post);
    	}
    	$sd_address .= '</div>';
    	$sd_address .= '<div class="sd-address">';
    	if ( geodir_is_page( 'detail' ) && !empty( $post ) && !empty( $post->post_neighbourhood )  && defined( 'GEODIRLOCATION_VERSION' ) ) {
    		if ( get_option( 'location_neighbourhoods' ) && $neighbourhood_info = geodir_location_get_neighbourhood_by_id( $post->post_neighbourhood, true, $post->post_location_id ) ) {
    			$sd_address .= '<div class="sd-neighbourhood" style="clear:both;"><span class="geodir-i-neighbourhood" style=""><i class="fa fa-location-arrow"></i> ' . __( 'Neighbourhood:', 'geodirectory' ) . ' </span> ' . $neighbourhood_info->hood_name . '</div>' . $social;
    		}
    	}
    	$sd_address .= '</div>';
    	$sd_address .= '<div class="sd-address">';
    	if (isset($post->post_city) && $post->post_city) {
    		$sd_address .= apply_filters('sd_detail_city_name', $post->post_city, $post);
    	}
    	if (isset($post->post_region) && $post->post_region) {
    		$sd_address .= ', ' . apply_filters('sd_detail_region_name', $post->post_region, $post);
    	}
    	if (isset($post->post_country) && $post->post_country) {
    		$sd_address .= ', ' . apply_filters('sd_detail_country_name', __($post->post_country, 'geodirectory'), $post);
    	}
    	$sd_address .= '</div>';
    
    	return $sd_address;
    }
    add_filter( 'sd_details_output_address', 'gd_custom_sd_details_output_address', 10, 2 );
    #384123

    Tania Perez
    Full Member
    Post count: 299

    Perfect!!!!! Thank you!!

    #384127

    Tania Perez
    Full Member
    Post count: 299

    Sorry, thought it was done, but some listings are, and some are showing a huge space between the address and the rest of the listing, or pulling some info from line 2, which are the reviews and comments.

    I´m attaching 2 images

    On mobile it looks exactly like it should. I´m attaching an image too

    Thank you!!

    #384130

    Tania Perez
    Full Member
    Post count: 299

    This is how it looks on mobile, which is perfect.

Viewing 15 posts - 1 through 15 (of 25 total)

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

Open Support Ticket