• I’m creating a custom theme (first time). The site will have 3 separate pages but about, services and contact sections are all on the front page. Setting a linking to a section of the same page is easy, but I wasn’t sure of the proper way to do this from another page.

    I was actually able to accomplish this by replacing #about with /wordpress6/?page_id=48/# but something tells me this is hack and there is a better way. I notices a slight delay when on the same page and clicking on about when linked like this. With #about it’s immediate.

Viewing 1 replies (of 1 total)
  • Moderator bcworkz

    (@bcworkz)

    Appending #about is correct. # alone will not get one to the “about” section. If it appears to work for you, it’s coincidental. Try it from a new browser instance and you’ll see. You don’t really need the / between 48 and #about, but I don’t think it does any harm.

    When following a # type skip link, if it’s a full, complete URL, the page will reload, causing a delay. If it’s just a relative #about link, the browser will skip to the location without reloading. But you cannot have such relative links in a menu used on other pages because the link needs the page information as well as the section.

    You could have code make such links relative only when on the appropriate page. leaving full URLs when on other pages. You could modify menu HTML through the “wp_nav_menu” filter, applying some conditional logic.

Viewing 1 replies (of 1 total)
  • The topic ‘Menu links to specific sections of another page’ is closed to new replies.