I want to add custom PHP code to ensure that whenever a page on my site loads in my browser, the URL of that page is echoed to the screen. I can use echo get_permalink()
, but that does not work on all pages. Some pages (e.g. my homepage) display several posts, and if I use get_permalink()
on these pages, the URL of the displayed page is not returned (I believe it returns the URL of the last post in the loop). For these pages, how can I return the URL?
Can I attach get_permalink()
to a particular hook that fires before the loop is executed? Or can I somehow break out of the loop, or reset it once it is complete?
Thanks.
is_home()
oris_page( 'fr' )
etc and only enqueue the script if it's true?if ( home_url( $wp->request ) == home_url() ) { wp_enqueue_script();}
This appears to fire on every home page, regardless of language. Is that what you were suggesting?$_SERVER['REQUEST_URI']
and company? See this question: stackoverflow.com/q/6768793/247696