Support » Developing with WordPress » Page jump from other pages

  • My top menu has 2 links to sections that are both on my home page. Here are the only two choices of setting them up that I can see

    1) Smoothly scroll to the sections but then they only work for that page and no others (ie. #about)

    2) Jump to the section from any page, but when on the same page it still jumps abruptly instead of the smooth scroll (ie. /wordpress7/?page_id=11#about)

    Is there a way that I can incorporate the best of both worlds? Perhaps an if statement of sorts that will run one or the other depending on the page I’m on?

    Right now in my custom theme I set the menus from my dashboard. They are not coded directly in my php files.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Is the smooth scroll animation something that you’re building, part of a theme, or plugin? If it’s something that you’re building you could probably work around this issue with Javascript ( maybe nav item classes too ). If it’s something that comes with a pre-built theme or pre-built plugin you might reach out to the theme/plugin authors. They’ll know the best solution.

    Part of my theme. In my menu the ‘About’ and ‘Services’ just taken me to a section of the home page. I set the scroll-behavior: smooth in the html of my css and that’s pretty much the extent of it.

    I would like for that behavior to stay but also be able to get to those sections from other pages. In order to do that I have to point the menu links to the home page and then to the section, but when I am on the home page and click on those links the page reloads instead of just scrolling smoothly to the section.

    I’m wondering if I could somehow set a condition to do one or the other depending on the page you are on. Or I guess I could create separate menu to display on all other pages accept the home page? Can that be done?

    Moderator bcworkz

    (@bcworkz)

    You could have separate menus, but I despise redundant data on principle, it’s something to avoid. You can filter the menu output using the “wp_nav_menu” filter. You can use the is_front_page() function in a conditional to strip out the home page main URLs, leaving only the #about portion any time the front page function returns true.

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.