Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+1 vote
1.7k views
in Q2A Core by
If I want to access the Base URL of my Q&A site in my custom theme. How can this be done? For instance, if I the url of my Q2A site is www.mygoodqa.com then how do I get this value in the custom theme?

1 Answer

+2 votes
by
selected by
 
Best answer

Try $this->root_url or $this->rooturl in theme file This will give you theme file (directory) root URL

To get site root URL use qa_opt('site_url')

by
Thanks @jatin.soni. I have another question. SO can I use following code to get current question page URL?

str_replace("///","/",str_replace("..","",qa_opt('site_url').$q_view['url']))

Is there any other elegant way to get the current question page's full url?

Thanks.
by
Try with super global $_SERVER something like this
qa_opt('site_url') . $_SERVER['REQUEST_URI']; in most case it should work.
by
I was trying to avoid the request_uri as it would required to sanitise it before putting it to use. Anyways thanks again buddy!
by
Note that some users had problems as qa_opt('site_url') did not work for them. Probably they had set it incorrectly or changed later on. I came across this issue when getting "bug" reports from users for this plugin: https://github.com/q2apro/q2apro-on-site-notifications/blob/master/CONTRIBUTING.md
...