Jump to content

PHP & Wordpress Code for Domain URL


Dhira

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]"
and
[code]<a href="/sitemap.html" target="_blank">Sitemap</a>[/code]gives me
"[b]http://www.subdomain.domain.com/sitemap.html[/b]",
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.
Link to comment
https://forums.phpfreaks.com/topic/7013-php-wordpress-code-for-domain-url/
Share on other sites

Archived

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

×
×
  • Create New...

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.