• Hi,

    sorry for the stupid question, but I’m struggling to understand how to highlight links to other pages, without a section with an id. Or is an id necessary?
    If so, how I have to set it up?

    Let’s assume I have an “about us” page. And when someone visits ‘https://my-site.com/about-us’ the link in the navigation should be highlighted.

    To make it work do I have to create something like my-site.com/about-us/#about-us’ ?
    That would look very strange. I guess that is not the correct way of doing it?!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author malihu

    (@malihu)

    Hi,

    The plugin will only highlight links that are handled by it. These are links that have a URL in the form of /about-us/#about-us that point to an existing target (like about-us). It does not highlight other links that are out of its scope.

    The highlighting of other links like https://my-site.com/about-us/ or https://my-site.com/blog/some-post/ is handled solely by the theme.

    Almost all WordPress themes highlight the current post/page link using WordPress built-in functions. If your theme does not have this (common) feature, you’d need to contact your theme’s developer and ask if this feature is missing or what CSS you need to add to use it.

    Hope this helps

    Thread Starter maddinb

    (@maddinb)

    Hey,

    Thank you, I’m aware of that. The problem is, I don’t know how to make the highlighting handled by the plugin and the highlighting handled by the theme work together.

    Let’s say I have the home page with multiple anchor links. I want those links to be handled by the plugin only. And there are other pages without anchor links, should be handled by the theme.

    To be more specific:
    The plugin highlight links like https://my-site.com/#about-us. But WordPress highlights all of them as well. I don’t want that. Now I could simply change those WordPress stylings to look neutral, but that would also affect the links to other pages like https://my-site.com/data-privacy which I don’t want. Those links I want to be highlighted by the theme but they wouldn’t be highlighted now.

    Plugin Author malihu

    (@malihu)

    I see. You need to change the WordPress theme CSS in way that a)it highlights “Page scroll to id” links and b)keeps WordPress highlighting for the other pages.

    The most common way of doing it, is using a combination of “Page scroll to id” and WordPress highlight classes together.
    For example, you could use the class _mPS2id-h (which is the class the plugin uses to determine the highlighted links) like this:

    .current-menu-item a:not(._mPS2id-h), 
    .current_page_item a:not(._mPS2id-h){
      /* 
      CSS for same-page WordPress links that are not handled by "Page scroll to id"
      */
    }
    .current-menu-item a._mPS2id-h, 
    .current_page_item a._mPS2id-h{
      /* 
      CSS for same-page WordPress links that are also handled by "Page scroll to id"
      i.e. you could change the WordPress styling to look neutral here
      */
    }
    .menu-item a._mPS2id-h.mPS2id-highlight{
      /* 
      CSS for highlighting the links that are handled by "Page scroll to id"
      */
    }

    Any combination of the above will probably work but it depends on how your theme applies its styling (e.g. how specific its CSS selectors are).

    Please keep in mind that I can’t really provide an exact solution to such issue unless I see your page. If you can post or send me your site link I’d be able to tell exactly what CSS to add. If you can do this I’d be happy to help ??

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Multipage – highlighting links’ is closed to new replies.