Last active
August 10, 2016 13:18
-
-
Save hirejordansmith/3738dc03933afb8ca929d97a009e34b0 to your computer and use it in GitHub Desktop.
How to Get the Current Page URL with PHP
This file contains 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 | |
// Non WordPress | |
$current_url = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]"; | |
// WordPress Site | |
global $wp; | |
$current_url = add_query_arg( $wp->query_string, '', home_url( $wp->request ) ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment