Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+1 vote
928 views
in Q2A Core by
reopened by

https://www.question2answer.org/qa/71112/how-to-change-the-nav-link-of-question-to-external-link(refer this link please)

I want to acheive the same functionality for tags,where i need to modify the nav-link of tags...

Solution by pupi for modifying the nav-link of question:

1. Locate this line: https://github.com/q2a/question2answer/blob/3320b653f94ffa1f004d51cc82f0e95f573ff411/qa-theme/SnowFlat/qa-theme.php#L365

2. Add in there this text:

$q_item['url'] = 'https://www.google.com/search?q=' . $q_item['title'];
by
What you’re asking doesn’t make sense to me. Why don’t you just redirect the whole site in htaccess?
by
@scott....

Because, i need that functionality for my upcoming website

1 Answer

+1 vote
by
selected by
 
Best answer

1. Locate this line: https://github.com/q2a/question2answer/blob/3320b653f94ffa1f004d51cc82f0e95f573ff411/qa-theme/SnowFlat/qa-theme.php#L54

2. Copy/Paste this code:

public function post_tag_list($post, $class) {
    foreach ($post['q_tags'] as &$taghtml) {
        preg_match('@<a .*?>(.*?)</a>@i', $taghtml, $matches);
        $taghtml = preg_replace(array('/href=".*?"/i'), array(sprintf('href="https://www.google.com/search?q=%s"', qa_html($matches[1]))), $taghtml);
    }
    parent::post_tag_list($post, $class);
}
by
edited by
Thank you very much puppi,

it works fine for me.....
by
pupi can you tell me ,how to make the link open in new tab or window
by
Replace:
sprintf('href="https://www.google.com/search?q=%s"', qa_html($matches[1]))
with:
sprintf('target="_blank" href="https://www.google.com/search?q=%s"', qa_html($matches[1]))
...