Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › slug problem
This topic contains 17 replies, has 2 voices, and was last updated by Ernest Marcinko 1 year, 8 months ago.
- AuthorPosts
- May 21, 2021 at 10:05 am #33355
Hello,
I am using wpml and translated the site into Turkish from English. I also use buddypress for member directory. Yestedday, I changed the members directory slug in Turkish site. However, the Ajax search is still bringing me to the previous slug that ends up in not finding the page for member and goes to home gape.
the previous slug was: https://www.uzmanhekimler.com/members/
I changed it to https://www.uzmanhekimler.com/uzmanlar/When I search from Ajax search pro, it brings me to https://www.uzmanhekimler.com/members/menguhan-araz-altay/
However, it should go to https://www.uzmanhekimler.com/uzmanlar/menguhan-araz-altay/How can I achieve this?
May 21, 2021 at 12:11 pm #33358Hi,
Tough questions, it should automatically return the correct URL as it is requested from WordPress, so the WPML filters should execute.
Try this custom code to force the WPML language filters:
Best,add_filter('asp_results', 'asp_change_wpml_link_users', 10, 1); function asp_change_wpml_link_users( $results, $id, $is_ajax, $args ) { if ( $args['_wmpl_lang'] != '' ) { foreach ( $results as $k => &$r ) { if ( $r->content_type == 'user' ) { $r->link = apply_filters('wpml_permalink', $r->link, $args['_wpml_lang'], true); } } } return $results; }
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
May 21, 2021 at 2:11 pm #33360Thanks but it did not work. I get the problem shown in the ss if I add the code.
Attachments:
You must be logged in to view attached files.May 21, 2021 at 5:22 pm #33365I deactivated and then reactivated the plugin just to see whether the reason is about it. But now the slug problem persists and I havr anothe rproblem. I change the theme but it is not reflected. I dont know what is happening.
May 22, 2021 at 9:41 pm #33369I fixed the theme problem but slug problem is still there and is a very important problem. I would appreciate if you could help me fix it
May 22, 2021 at 9:54 pm #33370I found the reason of the problem but dont know the solution. In buddypress settings, I should choose the member directory page. If I select the Turkish translated page, Ajax pro looks for Turkish slug in english pages. If I select the english page, Ajax pro searches using the English slug in Turkish page. I attached a ss
Attachments:
You must be logged in to view attached files.May 24, 2021 at 9:24 am #33377Can you pelase add temporary FTP access? I would like to debug that custom code to see what is wrong exactly.
Best,
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
May 24, 2021 at 9:30 am #33379You cannot access this content.May 24, 2021 at 9:33 am #33380You cannot access this content.May 24, 2021 at 2:43 pm #33386Thanks!
Okay, so I debugged through this, and found absolutely nothing at all. No matter what I do, always the incorrect link is returned. I don’t know if this is an issue with WordPress or WPML or there is something else conflicting, but for now I could only come up with a custom coded solution:
add_filter('asp_results', 'asp_change_wpml_link_users', 10, 4); function asp_change_wpml_link_users( $results, $id, $is_ajax, $args ) { $replace = array( 'tr' => '/uzmanlar/' ); if ( $args['_wpml_lang'] != '' && isset($replace[$args['_wpml_lang']]) ) { foreach ( $results as $k => &$r ) { if ( $r->content_type == 'user' ) { $r->link = str_replace('/members/', $replace[$args['_wpml_lang']], $r->link); } } } return $results; }
I palced this to the functions.php, it is in effect now.
This will replace the incorrect string with the correct one for the turkish site. The problem is very likely a bug somewhere else, I assume it is most likely WPML, but I don’t want to point any fingers, because I don’t know much. Unfortunately I can not guarantee this is going to work in all cases.
Best,
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
May 24, 2021 at 5:01 pm #33388I appreciate your help. Thank you very much. So If I dont change the Turkish slug, it will work though I get an update. Right?
May 25, 2021 at 8:02 am #33392Yes, it will work if the slug is not changed.
Best,
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
May 25, 2021 at 10:42 pm #33408You cannot access this content.May 26, 2021 at 2:35 pm #33430You cannot access this content. Best,
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
June 4, 2021 at 9:19 am #33533You cannot access this content. - AuthorPosts
You must be logged in to reply to this topic.