I have no idea, how to make a post visible only to one or 2 countries. How will the code gets to know, from which country the user is? Give me some hints and tips. It should be without making any account.
There are a lot of server variables like $_SERVER["REMOTE_ADDR"], $_SERVER['HTTP_CLIENT_IP'] etc by which you can find the logged in user's IP address.
Check out: PHP Server variables
Once you retrieve those, there are quite a few API's which could be used to determine the user's country.
You can use these as references:
You can determine their country from their ip. Check this site out: http://ipinfo.io/.
$.get("http://ipinfo.io", function(response) {
if (response.country == 'whatever country') {
// show whatever content
}
}, "jsonp");
Apply the IP out of Server into an API. The manual describes one such set of functions. http://php.net/manual/en/book.geoip.php
there are several options
$country_code = $_SERVER["HTTP_CF_IPCOUNTRY"];
https://support.cloudflare.com/hc/en-us/articles/200168236-What-does-CloudFlare-IP-Geolocation-do-