Hyperlinks Error in Questions and Answers

3.73K viewsUpdates
0

When adding a hyperlink in either a question or an answer, my site (or the plugin) adds my home URL to the link and causes a 404 error.

 

I have added the nofollow php code suggested in thsi forum. When I remove it, the problem goes away. The code I have is:

/**
* This filter will add rel=”nofollow” in all external links.
* */

function my_addrel_nofollow_inqa ($content){
global $post;
if(‘answer’ == $post->post_type || ‘question’ == $post->post_type){
return wp_rel_nofollow($content);
}
return $content;
}
add_filter(‘the_content’, ‘my_addrel_nofollow_inqa’);

 

See hyperlinks in both Q and A here: http://www.greennetblog.com/questions-and-answers/question/nofollow-question/?show_answer=267#answer_267

I am wanting nofollow in both question and answer links created by users. Also, is there a way to force open in new tab for links?

1

Please install this plugin:

External Links

This is really great advice! Have not tested it’s performance(speed) yet, otherwise it works great. Now I see why you don’t want to implement it in AnsPress.

Still, there must be an option to restrict transforming to /anspress/ only. It’s not a good seo practice, and not a good thing in general to never give dofollow links. Can’t whitelist just “nofollow”, it will also whitelist target=_blank.

Will try to tweak the links plugin to find a place where “just for anspress” condition can be inserted, will contact it’s author otherwise. Not a top priority currently.

Just added it. 🙂