Return to Snippet

Revision: 21807
at December 21, 2009 21:26 by jonhenshaw


Initial Code
<?php         
function curPageURL() {
$pageURL = 'http';
if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
$pageURL .= "://";
if ($_SERVER["SERVER_PORT"] != "80") {
$pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
} else {
$pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
}
return $pageURL;
}
?>

<?php echo curPageURL(); ?>

Initial URL
http://dailypaste.wordpress.com/2008/10/26/php-get-current-url/

Initial Description
This script will return the URL for the current page you're on, including category and tag pages.

Initial Title
Get Current Page URL (Context) for WordPress

Initial Tags
url, wordpress

Initial Language
PHP