Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
0 votes
277 views
in Q2A Core by
public function logo()
    {
        $this->output(
            '<div class="qa-logo">',
            $this->content['logo'],
            '</div>'
        );
    }

 $this->content['logo'] generates <a class="qa-logo-link" href="./">Website name</a>.

How to change the default behaviour, e.g. to add another classname to <a> tag

1 Answer

+1 vote
by
selected by
 
Best answer

It comes from the core that way. So without hacking the core, you have 2 options.

Alternative 1

1. Locate the code from the core that generates that HTML here: https://github.com/q2a/question2answer/blob/7aa2774a87482e9143cf4da9aa650760a5cd57e6/qa-include/qa-page.php#L678

2. Copy the code and paste it in that function

3. Add whatever HTML you want

4. The resulting function should look like this:

public function logo() {
    $newLogo = '<a href="'.qa_path_html('').'" class="qa-logo-link another-class" ... </a>;
    $this->output(
        '<div class="qa-logo">',
        $newLogo,
        '</div>'
    );
}

Alternative 2

1. Just output your desired HTML

2. The resulting function should look like this (based on your example)

public function logo() {
    $this->output(
        '<div class="qa-logo">',
        '<a class="qa-logo-link another-class" href="./">Website name</a>',
        '</div>'
    );
}

Alternative 3

1. You could also apply a string replacement that would search for qa-logo-link and replace it with qa-logo-link another-class

...