How can I get wordpress to automatically print the url of a that page on every page. Ex: You are browsing (URL here) (Using the same seo friendly urls as I set in the admin panel)
Hey, check out the php section on $_SERVER variables: http://us2.php.net/reserved.variables.server Specifically you would want HTTP_HOST and PHP_SELF. I think what your looking for would be like: echo "http://" . $_SERVER['HTTP_HOST'] . $_SERVER[PHP_SELF]; PHP: That should give you what you need.
Thanks. That might work but after having slept I found a more wordpress suitable solution: <?php the_permalink() ?> Code (markup):
No no no, this is bad code. It has an XSS exploit. What he wants is echo "http://" . $_SERVER['HTTP_HOST'] . $_SERVER['SCRIPT_NAME']; you see, echoing php self can lead to XSS exploits by accessing http://site.com/file.php/<script>alert('XSS')</script> this is why you should use script name, or escape PHP self with htmlspecialchars or entities here's a demonstration of how PHP_SELF behaves: http://wocares.com/analyzerer.php/XSSHERE
The above answers will not work on https or other ports. Taken from webcheatsheet.com: <?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: Peace,