Get the Domain Name in Wordpress

This is a helper function which will allow you to get the domain name in Wordpress both when in WEB and CLI mode:


function getDomain() {
        return $_SERVER['HTTP_HOST'];
        $url = get_site_url();
        return parse_url($url,PHP_URL_HOST);
        return basename(BASE_PATH);
    return dirname(__DIR__);


Please Do Not Reprint This Article

This article is copyrighted. Please do not reproduce or distribute this article in whole or part, in any form. Links to this article are welcome

Other Related Articles