How to remove nofollow from link URLs

By default, GeoDirectory will add "nofollow" to the output to user-entered external URLs.  This is done for SEO reasons, to retain "link juice".

We recommend that you keep things this way but if for some reason you wish to allow "dofollow" links to external URLs you can do this using the snippets below. (You can add this snippet via the code snippets plugin)

Remove "nofollow" from ALL URLs

add_filter('geodir_custom_field_output_url','_my_remove_all_nofollow',20,5);
function _my_remove_all_nofollow($html,$location,$cf,$p='',$output=''){
	
	if($html){
		$html = str_replace('rel="nofollow"','',$html);
	}
	
	return $html;
}

Remove "nofollow" from SELECT URLs

add_filter('geodir_custom_field_output_url','_my_remove_select_nofollow',20,5);
function _my_remove_select_nofollow($html,$location,$cf,$p='',$output=''){
	// list of allowed URLs
	$allowed_urls = array(
		"https://example.com",
		"http://www.morimotorestaurant.com"
	);
	
	if($html && !empty($allowed_urls) ){
		foreach($allowed_urls as $allowed_url){
			if(strpos($html, $allowed_url) !== false){
				$html = str_replace('rel="nofollow"','',$html);
			}
		}
		
	}
	
	return $html;
}
Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.

Still need help? Contact Us Contact Us