Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › Problem with Redirect
This topic contains 3 replies, has 2 voices, and was last updated by Ernest Marcinko 1 year, 11 months ago.
- AuthorPosts
- March 30, 2021 at 4:22 pm #32437
Hello,
I added a redirect as instructed by this code// Remove the line below, if you don't want to affect the Live results list add_filter( 'asp_results', 'asp_custom_link_meta_results', 10, 4 ); // Remove the line below, if you don't want to affect the results page add_filter( 'asp_noajax_results', 'asp_custom_link_meta_results', 10, 4 ); function asp_custom_link_meta_results( $results, $search_id, $is_ajax, $args ) { // Change this variable to whatever meta key you are using $meta_key = 'strona_odnoszaca'; // --- DO NOT CHANGE ANYTHING BELOW --- foreach ($results as $k=>&$r) { if ( function_exists('get_field') ) $new_url = get_field( $meta_key, $r->id, true ); // ACF support else $new_url = get_post_meta( $r->id, $meta_key, true ); // Change only, if the meta is specified if ( !empty($new_url) ) { // Ajax results link if ( isset($r->link) ) { $r->link = $new_url; } // Results page link if ( isset($r->asp_guid) ) { $r->asp_guid = $new_url; } } } return $results; }
But not everything works well. By typing a word in the menu search engine, when possible redirects are displayed, when you click on one it actually takes you to the page from ACF, it works.
And after we click on it
But when we click Enter and go to the Search Results page, when we click on topic, it still takes us to the selected articles.
And after we click on it
You can check this on my website
March 31, 2021 at 1:17 pm #32461Unfortunately the search results page links in most cases can not be affected by the plugin. It tries to send it’s own links, but in most cases the theme takes over and changes it back.
Best,
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
March 31, 2021 at 1:20 pm #32462So what are the possible solutions?
Can I deactivate the search results page?
Add some custom code?
I would need urgent help with this problemMarch 31, 2021 at 3:02 pm #32476Custom code may not work, but directly editing the template file may actually be possible. There are template functions available.
You could try finding the template part, where the search result URL is printed to the screen. Then replace the function, which prints the URL with this:the_asp_result_field('link');
If all goes well, and nothing reset the query from earlier, then this should return the URL same as the live search.
Best,
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
- AuthorPosts
You must be logged in to reply to this topic.