Forum: F.A.Q

This forum is closed for new topics. However, you can still search for a solution in the old topics. For technical support and general questions related to GEO my WP plugin and its core add-ons please use the support forum.

[Not a support question]Echo distance inside post

Home Forums F.A.Q Echo distance inside post

This topic contains 5 replies, has 2 voices, and was last updated by  Eyal Fitoussi 4 years, 10 months ago.

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #32950

    mattmatt
    Participant

    Hello,

    I have the results page witch shows me the distance of the user to this posts (custom post type) correctly.

    What can I do if I want the distance to be echoed inside the single post page again?

    Thank you.

    #32955

    Eyal Fitoussi
    Keymaster

    Hey Matt,
    Do you mean a single post page which displaying a certain the post after redirecting from the list of results? or simply echo it again within the list of results?

    #32954

    mattmatt
    Participant

    ,Yes, a single post page.

    The distance is automatically displayed on each post found in the results page. I need some piece of code to also display the same distance in the single.php.

    #32953

    Eyal Fitoussi
    Keymaster

    Hey Matt,
    You will need to pass the distance via URL to the single page.

    Apply the script below to the functions.php file of your theme. The script should append the distance to each permalink in the search results:

    Now, once you click on the post title in the results take will take you to the single page you should see the address arg added to the url ( ex. http://www.mysite.com/my-post/?address=some-address&distance=some-distance ).
    If the above is true than you can pull the distance to your single.php file using $_GET[‘distance’].

    I hope that helps.

    #32952

    Eyal Fitoussi
    Keymaster

    For some reason the code is not properly shows above.

    Replace the character &#038 with & in:

    so it will look like :
    return $url. “&distance=”.$distance;

    #32951

    mattmatt
    Participant

    Thank you for that answer.

    The problem is that users can also open the single posts without using the search form by using a list of posts (which doesn’t use any distance settings). So, I need to calculate the distance between the address again in the single.php.

    I have the address of the logged in user in a variable “$user_address”.
    Is there a function that I can use to calculate the address between the user address and the address in the post?

    Thanks a lot

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

You must be logged in to reply to this topic.