add_filter('get_the_permalink','my_permalink_redirect');
function my_permalink_redirect($permalink) {
global $post;
if ($post->ID == 6342) {
$permalink = '/en/about-us/vision/';
}
return $permalink;
}
That should redirect when page is opened to another page, but i have two languages: English and Slovenian. When i try to go to english and open this page, it redirects to slovean page not the english one.
From what I understand, if the current postID is 6342, you are redirecting to the English page. Please note that the postID is different for a page & the translation of that page.
So when you change the language the postID is not matched & hence it will not be redirected to the given link.
No, That is page that is alredy translated to english, its an page that is only for SEO, it's empty, and if you try to access it it should redirect to page that has this page as parent. So the url will look like /services/service1. I hope you understand me.
This is what I understood from your code:
1. if the postID == 6342, then you set the $permalink value to "/en/about-us/vision/"
2. when you switch language, it's not working
While switching language, please try to print the value of the postID & make sure that the value is 6342.
If this is not what you are asking, could you please explain this in a more detailed/step by step way so that I can understand better.