Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › set specific url for search results › Reply To: set specific url for search results
March 15, 2021 at 9:30 am
#32166
Keymaster
Hi,
Actually, there might be a programmatcial solution, but it is definitely not a simple one. In this knowledge base, a frontend hook is presented, which allows changing the magnifier and return button redirection URLs programmatically.
This could be used for this purpose. You could basically check the phrase, and then change the URL according to that.
Maybe starting with something like this:
add_action('wp_footer', 'asp_change_redirect_uri');
function asp_change_redirect_uri() {
?>
<script>
jQuery(function($){
wp.hooks.addFilter('asp_redirect_url', 'asp', function(url, id, instance){
var redirect = url;
var urls = {
'phrase 1' : 'https://my-custom-url.com/1',
'phrase 2' : 'https://my-custom-url.com/2',
'phrase 3' : 'https://my-custom-url.com/3'
};
var phrase = $('.asp_m_' + id + '_' + instance).find('input.orig').val();
$.each(urls, function(s, uri) {
if (s == phrase) {
redirect = uri;
}
});
return redirect;
}, 10);
});
</script>
<?php
}