+1 vote
in CMS Tips by (56.8k points)
Under "Administration Center - General", I can add only the "Q&A site name". I checked other Admin pages but did not find an option to add a custom title for the homepage only. As a result, the homepage shows "Q&A site name" as the title. How can I change it?

1 Answer

+1 vote
by (351k points)
edited by
 
Best answer

To add a custom title for the homepage of the Q&A site, you need to add a few lines of PHP code to the file "qa-include/qa-theme-base.php".

Open the file in any editor and search for the "head_title()" function. Add the following highlighted code to this function to change the title of the homepage.

qa-include/qa-theme-base.php

public function head_title()

{

$pagetitle = strlen($this->request) ? strip_tags(@$this->content['title']) : '';

$headtitle = (strlen($pagetitle) ? "$pagetitle - " : '') . $this->content['site_title'];

// custome title for the homepage

if ($_SERVER['REQUEST_URI'] === '/'){

$headtitle = "WRITE_YOUR_CUSTOM_TITLE_HERE" . ' - ' . $headtitle;

}

}

 Replace "WRITE_YOUR_CUSTOM_TITLE_HERE" with your title. That's it; now your homepage will have a custom title. The above code assumes that you have not installed Q&A CMS in a folder. 

If you have installed Q2A CMS in a folder, then make this additional change in the above code:

From

if ($_SERVER['REQUEST_URI'] === '/')

to

if ($_SERVER['REQUEST_URI'] === '/FOLDER_NAME/')


...