Jump to content


This topic is now archived and is closed to further replies.


PHP & Wordpress Code for Domain URL

Recommended Posts

Hi all,

Wordpress is full of php code to refer to the blogs location.

I need the code to refer to the url of the domain, even if wordpress is installed on a subdomain.

For example if I want to place a link for hte home page, I would use this
[code]<a href="" target="_blank">Home Page</a>[/code]
for a site map I'd use:
[code]<a href="/sitemap.html" target="_blank">Sitemap</a>[/code]

That works fine if the worpress blog is installed in the root of a domain or in a subfolder.
It does not work accurately if the blog is in a subdomain.
If I use the above, the urls show up as:
[code]<a href="" target="_blank">Home Page</a>[/code]
which gives me
"[b]http://www.subdomain.domain.com[/b]" instead of "[b]http://www.domain.com[/b]"
[code]<a href="/sitemap.html" target="_blank">Sitemap</a>[/code]gives me
instead of
"[b]http://www.domain.com/sitemap.html[/b]" which I would like.

I've tried [code]<a href='$ require($_SERVER["DOCUMENT_ROOT"]);/sitemap.html">Sitemap</a><br>[/code]and variations of it to no avail. Help appreciated.

Share this post

Link to post
Share on other sites


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.