<?xml version="1.0" encoding="UTF-8"?>        <rss version="2.0"
             xmlns:atom="http://www.w3.org/2005/Atom"
             xmlns:dc="http://purl.org/dc/elements/1.1/"
             xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
             xmlns:admin="http://webns.net/mvcb/"
             xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
             xmlns:content="http://purl.org/rss/1.0/modules/content/">
        <channel>
            <title>
									Wordpress - How to get URL of current page displayed? - Web Development				            </title>
            <link>https://www.tweaking4all.com/forum/web-development/wordpress-how-to-get-url-of-current-page-displayed/</link>
            <description>Tweaking4All.com Discussion Board</description>
            <language>en-US</language>
            <lastBuildDate>Tue, 21 Jul 2026 01:14:57 +0000</lastBuildDate>
            <generator>wpForo</generator>
            <ttl>60</ttl>
							                    <item>
                        <title>Wordpress - How to get URL of current page displayed?</title>
                        <link>https://www.tweaking4all.com/forum/web-development/wordpress-how-to-get-url-of-current-page-displayed/#post-4491</link>
                        <pubDate>Tue, 18 Oct 2022 15:41:10 +0000</pubDate>
                        <description><![CDATA[I&#039;ve found this one surprisingly unreliable when going through all the available methods.
I&#039;ll start with the one that worked reliably for my website:
$current_url = home_url($_SERVER[&#039;REQ...]]></description>
                        <content:encoded><![CDATA[<p>I've found this one surprisingly unreliable when going through all the available methods.</p>
<p>I'll start with the one that worked reliably for my website:</p>
<pre contenteditable="false">$current_url = home_url($_SERVER);</pre>
<p>Now some will complain about using the "REQUEST_URI" option, so here some alternatives that proved to be not always reliable, depending on your circumstances.</p>
<pre contenteditable="false">// Option 1
// requires $wp, may not work with permalinks set to plain
global $wp; 
$current_url = home_url( $wp-&gt;request );

// Option 2
// requires $wp, may not work with permalinks set to plain
global $wp;
$current_url = add_query_arg( $wp-&gt;query_vars, home_url( $wp-&gt;request ) );

// Some other options that may be helpful:
$current_url = get_permalink( get_the_ID() ); // for page
$current_url = get_category_link( get_query_var( 'cat' ) ); // for category
</pre>
<p> </p>]]></content:encoded>
						                            <category domain="https://www.tweaking4all.com/forum/web-development/">Web Development</category>                        <dc:creator>Hans</dc:creator>
                        <guid isPermaLink="true">https://www.tweaking4all.com/forum/web-development/wordpress-how-to-get-url-of-current-page-displayed/#post-4491</guid>
                    </item>
							        </channel>
        </rss>
		