Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › Horizontal search URL don't take correct language › Reply To: Horizontal search URL don't take correct language
June 22, 2020 at 3:35 pm
#28026
Keymaster
Hi,
Looks like the wpml_permalink call is not resolving the URLs correctly. I looked up their documentation, and there seems to be a way to force that. This requires a bit of custom code, but should hopefully work.
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_full_resolve_wpml', 10, 4);
function asp_full_resolve_wpml( $results, $id, $is_ajax, $args ) {
foreach ( $results as $k => &$r ) {
if ( isset($r->post_type) )
$r->link = apply_filters( 'wpml_permalink', get_permalink($r->id), $args['_wpml_lang'], true );
}
return results;
}
Let me know if it works.