• Resolved Xen

    (@aloveyu)


    my goal is simple, I need to create an Anchor link form top-page menu going to another page and landing to its specific section ID. I have these codes from default WordPress function:

    <a href="<?php echo home_url( '/#aboutus' ); ?>">About Us</a>
    
    <a href="<?php echo esc_url( home_url( '/' ) ); ?>#aboutus">About Us</a>
    
    <a href="<?php echo esc_url( home_url( '/' ) ) . "#aboutus"; ?>">About Us</a>
    

    unfortunately all these codes are not working. are there any ways how to achieve my goal?

    • This topic was modified 3 years, 9 months ago by Xen.
Viewing 3 replies - 1 through 3 (of 3 total)
  • In what ways are they “not working”? Can you describe exactly what happens?

    You mentioned you want the link to go to an anchor on another page. But all the code snippets you gave above reference the homepage itself. Is the homepage the “other page” with the specific section that you want to jump to?

    Also, where are you placing the code? In a theme template file where the PHP will be executed?

    Thread Starter Xen

    (@aloveyu)

    Hi George thank you for your message.
    I’d put the sample codes above on the “About Us” menu tab on my homepage to jump/anchor it to next/other page where the specific <section id=”aboutus”> located. but the problem is, when I tried to click the About Us menu tab it doesn’t work, it didn’t jump to the ID, nothing happened at all.

    I’ve placed the sample codes on my homepage menu tab. I am working with my own custom theme codes.

    Thread Starter Xen

    (@aloveyu)

    I already solved my problem. I just need to be careful with my javascript code to not be affect my href # (anchor) link. so I changed some of my javascript code.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Anchor Link to another page in specific section ID’ is closed to new replies.