PHP & WordPress Code for Domain URL
-
Hi all,
WordPress is full of php code to refer to the blogs location.
*(In the examples below I use “{” & “}” instead of “<” & “>”)*
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 the home page, I would use this
{a href=”” target=”_blank”}Home Page{/a}
for a site map I’d use:
{a href=”/sitemap.html” target=”_blank”}Sitemap{/a}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:
{a href=”” target=”_blank”}Home Page{/a}
which gives me:
“http://www.subdomain.domain.com”
instead of
“http://www.domain.com”
and
{a href=”/sitemap.html” target=”_blank”}Sitemap{/a}
gives me:
“http://www.subdomain.domain.com/sitemap.html”,
instead of:
“http://www.domain.com/sitemap.html” which I would like.I’ve tried {a href=’$ require($_SERVER[“DOCUMENT_ROOT”]);/sitemap.html”}Sitemap{/a}
and variations of it to no avail.
Help appreciated.
- The topic ‘PHP & WordPress Code for Domain URL’ is closed to new replies.