slug problem

This topic contains 17 replies, has 2 voices, and was last updated by Ernest Marcinko Ernest Marcinko 2 years, 9 months ago.

Viewing 15 posts - 1 through 15 (of 18 total)
  • Author
    Posts
  • #33355
    memcan71
    memcan71
    Participant

    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?

    #33358
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Hi,

    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:

    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;
    }
    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


    #33360
    memcan71
    memcan71
    Participant

    Thanks 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.
    #33365
    memcan71
    memcan71
    Participant

    I 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.

    #33369
    memcan71
    memcan71
    Participant

    I 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

    #33370
    memcan71
    memcan71
    Participant

    I 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.
    #33377
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Can 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 :)


    #33379
    memcan71
    memcan71
    Participant
    You cannot access this content.
    #33380
    memcan71
    memcan71
    Participant
    You cannot access this content.
    #33386
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Thanks!

    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 :)


    #33388
    memcan71
    memcan71
    Participant

    I appreciate your help. Thank you very much. So If I dont change the Turkish slug, it will work though I get an update. Right?

    #33392
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Yes, 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 :)


    #33408
    memcan71
    memcan71
    Participant
    You cannot access this content.
    #33430
    Ernest Marcinko
    Ernest Marcinko
    Keymaster
    You cannot access this content. Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


    #33533
    memcan71
    memcan71
    Participant
    You cannot access this content.
Viewing 15 posts - 1 through 15 (of 18 total)

You must be logged in to reply to this topic.