<?php echo $_SERVER['PHP_SELF'] ?>
If you want something else, then google “php get current url” to find the code snippet you need.
Thanks, the correct code is:
<?php echo $_SERVER[“HTTP_HOST”] . $_SERVER[“REQUEST_URI”] ?>
You can use get_permalink() outside the loop with an ID as a parameter:
<?php echo get_permalink( $post->ID ); ?>
If you are trying to detect if a user is viewing the home page, you can use is_home(), which is a WordPress specific function. In a conditional statement it would be used like this:
if(is_home()){
// code for home page goes here
}
I use this on my blog http://www.fatcatreport.com. If you look at the home page, I have an about us box on the right side. On all the other pages, I hide the box and display Google Ads.
You can use one of the following for other pages too:
is_category() – Use this if you want to detect if a user is viewing a category page. Or if you want to detect a specific category you can use something like is_category(‘SEO Tips’) for a category called ‘SEO Tips’.
is_single() – If user is viewing a post page. For a specific post use is_single(17) for a post with an id of 17. Or you can use is_single(‘WordPress Tips’) of a post with the title ‘WordPress Tips’.
Here is a complete list of conditional tags here: http://codex.ww.wp.xz.cn/Conditional_Tags
try : <?php the_guid($id); ?>