How to get URL of current page displayed?

Posted by Prem Tiwari | Updated on

This is an improved way of example that mentioned previously. It works when pretty URLs are enabled however it discards if there is any query parameter like /page-slug/?param=1 or URL is ugly at all.

Following example will work on both cases:


If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.

Related Questions & Answers