Hm, I’m not sure if I understood correctly. As far as I can see the “msls_options_get_permalink” works fine, if you have multiple pages and the permalinks are different (depending on language).
But I have only two pages, one in native language (www.example.com) and one in English (www.example.com/en), which are already linked together with msls.
But those two pages have bookmarks inside. So, when I choose f.e. the “Contact” in the main menu, the page just slides down to the bookmark and the hyperlink in the navigation bar is then “www.example.com/#contact”. If I then click on English flag, it just takes me to “www.example.com/en” and not to “www.example.com/en/#contact”.
So for this case I can’t see, what should I put after str_replace, as I’m not replacing anything in my permalink… Or should I replace only the bookmark including the language part of URL?
Furthermore, if this would work, could I put the all of my bookmarks replacement (f.e. #top, #contact, #about, #references) in the same function?
I added this to my functions.php:
function my_msls_options_get_permalink( $url, $language ) {
if ( 'us' == $language ) {
$url = str_replace( '/#top', '/en/#top', $url );
$url = str_replace( '/#about', '/en/#about', $url );
$url = str_replace( '/#competence', '/en/#competence', $url );
$url = str_replace( '/#contact', '/en/#contact', $url );
}
if ( 'sl_SI' == $language ) {
$url = str_replace( '/en/#top', '/#top', $url );
$url = str_replace( '/en/#about', '/#about', $url );
$url = str_replace( '/en/#competence', '/#competence', $url );
$url = str_replace( '/en/#contact', '/#contact', $url );
}
return $url;
}
add_filter( 'msls_options_get_permalink', 'my_msls_options_get_permalink', 10, 2 );
but it doesn’t work.
Any additional hint would be really appreciated.
-
This reply was modified 8 years, 3 months ago by
stipe.
-
This reply was modified 8 years, 3 months ago by
stipe.