Frage: "Hallo Team, gibt es einen Shortcode, der nur den Ländernamen anzeigt?"
Antwort: "Nein, aber es ist möglich, ihn mit dem folgenden Codebeispiel hinzuzufügen"
add_shortcode('woocs_get_current_country', function($atts) {
$pd = array();
$countries = array();
if (class_exists('WC_Geolocation')) {
$c = new WC_Countries();
$countries = $c->get_countries();
$pd = WC_Geolocation::geolocate_ip();
}
if (!empty($pd) AND!empty($countries)) {
return $countries[$pd['country']];
}
return 'Country is not defined';
});