Output: echo esc_url( mytheme_get_current_url() );
/**
* Get the current frontend URL.
*
* @return string
*/
function mytheme_get_current_url() {
global $wp;
return home_url(
add_query_arg(
array(),
$wp->request
)
);
}