Last active
December 17, 2015 03:19
-
-
Save wpscholar/5542587 to your computer and use it in GitHub Desktop.
A function for use within WordPress themes or plugins that fetches the current URL without the query string.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Helper function fetches current URL less the query string | |
* | |
* @return string | |
*/ | |
function get_url(){ | |
global $wp; | |
$url = parse_url( add_query_arg( $wp->query_string, '', home_url( $wp->request ) ) ); | |
return $url['scheme'] . '://' . $url['host'] . ( isset($url['path'] ) ? $url['path'] : '' ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment