How do I create a Shortcode that returns text if domain is .com, not .co.uk

to read the attribut country, you just need to read it in $atts

add_shortcode( 'ifurl', 'ifurl' );

function ifurl($atts, $content = null) {

 $url="https://" . $_SERVER['SERVER_NAME']; 
 $current_tld = end(explode(".", parse_url($url, PHP_URL_HOST)));

 if ($current_tld === $atts["country"]) {
  return $content;
 }

};

Leave a Comment