hi,
How can i get the url of current page to be stored in a variable.
I tried this,
echo get_permalink($ID);
and
the_permalink()
But that doesn't work with a blog page layout...
P.S I want the url to be stored in a variable like this.
http://www.mysite.com/blog
Try this function, it has worked pretty well for me:
function current_page_url() {
$pageURL = 'http';
if( isset($_SERVER["HTTPS"]) ) {
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;
}
Gave some Parse Error :'(
erikaslt
Member
Posted 5 months ago #
Thanks, David Gwyer,
it worked great for me :) i added your function to themes/my_theme/functions.php
and then used in header.php like this:
<?php echo current_page_url(); ?>