Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › blank spaces in url show %20 not – › Reply To: blank spaces in url show %20 not –
February 21, 2020 at 4:15 pm
#25928
Keymaster
Well, there might be a way to do that via custom code, but I am not sure if it would work.
First, change the custom URL structure, so that the {user_login} variable is not there at the end, so in your case I guess it’s:
profile/
Then, try adding this custom code to the functions.php in your theme/child theme directory. Before editing, please make sure to have a full site back-up just in case!
add_filter( 'asp_results', 'asp_custom_ur_url', 10, 1 );
function asp_custom_ur_url($results) {
foreach ( $results as $k => &$r ) {
if ( $r->content_type == 'user' ) {
$u = get_user_by('ID', $r->id);
$r->link .= preg_replace("/[^A-Za-z0-9 ]/", '-', $u->user_login);
}
}
return $results;
}
This should append the user login to the end of each user result URL, replacing any non-alphanumeric character with a dash.