Forum Replies Created

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter shove

    (@shove)

    Hey Dennis,

    this works very well in a first test. I think I can work with that. Thanks a lot for your fast help! And thanks also for the great plugin!

    Thread Starter shove

    (@shove)

    Hey Dennis,

    thanks for your fast reply. I already stumbled across this wiki page and it helped me understanding how your plugin works. One interesting thing I noticed : getting the permalinks for the related (translated) posts works well from within the specific post but not from within a page. For example I tried this hard-coded testing function in my functions.php.

    function my_test() {
    	// switch to german blog
        switch_to_blog( 3 );
    
    	// output the permalink for the german post with id 1
    	error_log( get_permalink(1) ); // german link
    	// test 1 from within a blog post outputs : https://localhost/wordpress/de/hallo-welt/
    	// test 2 from within a page outputs : https://localhost/wordpress/de/hallo-welt/
    
    	// get MSLS data for post with id 1
    	$mydata = MslsOptions::create( 1 );
    
    	// switch to us blog
    	switch_to_blog( 1 );
    
    	// output the permalink for the corresponding us post
    	error_log( $mydata->get_permalink('us') );
    	// test 1 from within a blog post outputs : https://localhost/wordpress/hello-world/
    	// test 2 from within a page outputs : https://localhost/wordpress/
    }

    When calling it from a blog post it works well and outputs both permalinks correctly. But called from within a page is outputs the base blog url instead of the permalink for the corresponding post.

Viewing 2 replies - 1 through 2 (of 2 total)