• Hi guys – I’ve created a simple social media site, and currently each user sees all posts on their feed. My users are dispersed geographically, and only want to see posts by users that are relatively close to them, so I need to find a way of only showing posts on their feed that are within a certain geographical radius of their location.

    Ideally, when they register, they’ll specify their own location and the radius for which they want to see posts from e.g. ‘all posts within 10 miles of my location’.

    I’m using the PeepSo plugin and have enabled the location option for posting, and have tried using the ‘GEO my WP’ plugin to achieve what I’ve set out above, but am not getting anywhere. I can’t find anything in the forums etc either so any help much appreciated.

    Many thanks!

Viewing 2 replies - 1 through 2 (of 2 total)
  • > have tried using the ‘GEO my WP’ plugin to achieve what I’ve set out above, but am not getting anywhere

    What do you mean by ‘not getting anywhere’ ?
    What was the problem ?
    Did you get support from their forum ?
    https://www.ads-software.com/support/plugin/geo-my-wp/
    Or try other solutions ?
    https://www.wpexplorer.com/wordpress-geotargeting-plugins/

    Moderator bcworkz

    (@bcworkz)

    If you want to code your own solution, assuming there are already latitude/longitude coordinates associated with each post and you’re able to determine the same for the user, getting posts within a certain distance is mainly a matter of applying the right maths.

    Getting accurate distances on the Earth’s surface is actually really complicated, as the planet is close to ellipsoidal in shape. Ellipsoidal geometry is just plain complicated. Fortunately, you can get reasonable approximations using much simpler spherical geometry.

    It’s still pretty complicated to work into a SQL query. Not being that strong with SQL, what I’ve done is determine an appropriate range of lat & long values into which the desired posts will fall. A rectangular-like area, where some posts in the corners would be outside the specified radius. That’s OK, as those are eliminated from the returned results through more calculations in PHP.

    I cannot provide my entire solution here, but if you’re interested I can provide some key snippets which you can use as guidance in coding up your own solution.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Display posts based on location’ is closed to new replies.