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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.