Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Dennis Ploetner

    (@realloc)

    Yes,

    yes, you can probably use the filter “msls_options_get_permalink”.

    Read on here: https://msls.co/hooks-filters-and-actions/

    Cheers,
    Dennis.

    Thread Starter stipe

    (@stipe)

    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.
    Plugin Author Dennis Ploetner

    (@realloc)

    I never tested this with a one page layout so I cannot help that much here, sorry.

    Thread Starter stipe

    (@stipe)

    OK, I see, I’ll try to figure it out myself somehow… but still, can you please tell me:

    1.) if I created the right concept in my functions.php? Is this the correct way to use it?

    2.) shall I call the function additionally in my page (in my header maybe?) or is it enough just to have it in functions.php?

    Thx in advance.

    Plugin Author Dennis Ploetner

    (@realloc)

    I think you can go with some code in your functions.php. There is no need for additional functionality in the header.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Links to bookmarks inside the page’ is closed to new replies.