-
-
I’m using the single page template, but I’ve got blog posts on the page. When you view one of the blog posts post, the top nav no longer functions since the links are in a format like #sec1. I attempted to change the links to include a / at the beginning (like /#sec1) but the smooth scrolling script doesn’t appear to like that and the nav stops functioning completely. Do you have a fix for this? Thanks!
-
I noticed something interesting which may help solve the problem. The links that have a / in front of them all have the current_page_item class on them on initial page load. Once you scroll down the page and something else picks up the current class, then all the links start working. That would make sense since the click handler ignores links when you are already on that section.
-
I spent some time looking at the jquery.onepage.js file to figure out why those classes are being added and just finally realized they are being added server-side. If you view the source, any link that doesn’t start with a # in the nav gets the following classes added to it – current-menu-item current_page_item menu-item-home. Do you know why that would happen or what files generate the navigation?
-
Hello,
If you have other pages except the onepage, you should add the link in the menu in this format: https://yoursiteurl.com/#sec1, jot just the section id ‘#sec1’.
Try this and let us know.
Best regards!
-
Unfortunately, that doesn’t work. Whether you use /#sec1 or https://sitename.com/#sec1, the link in the menu gets a current class added to it for some reason. That’s happening server side, so it has something to do with the code generating the menu.
-
Hello,
Do you have enabled the “One page” option? Please go to your page’s General Settings > Page options & Style > Use menu as one page menu, set it ON if you plan to use the full feature one page layout. This means only id’s will be added at the menu.
Or set it OFF, if you plan to keep the “https://sitename.com/#sec1” links in the menu.These related topics may help you find an answer:
https://support.codeless.co/?topic=onepage-menu
https://support.codeless.co/?topic=new-menu-on-interior-pages
Let us know.Best regards!
-
If you turn it off the one page nav, the menu links still have the current classes, but now the smooth scrolling is disabled. What is generating the “current-menu-item current_page_item menu-item-home” classes? I’m assuming if we could get rid of that, then everything would work fine.
-
Hello,
If all menu links are linking the same page, and the “One page” layout is not enabled, then ofcourse they will have the “current-menu-item” class enabled. Because all of them are pointing the current apge you are in.
Please know that One Page is a different layout and by default you can not have both the normal set up (external pages) and One page (link to section id’s) in the same site.
Smooth scrolling is a feature of One page. The moment you disable one page, that will go as well.The css classes are auto-generated based on the options you select. So it’s not possible to just get rid of some.
Can you post some valid wp credentials in a private reply? So we can give it a closer look.Best regards!
-
-
The main issue of the one page layout here is the addition of the current-menu-item class. It gets added for links like /#sec1 but not #sec1. I’m guessing that has something to do with the menu code for WordPress (in nav-menu-template.php) and may not be easily customized.
This might be fixable if a different class is used in your main.js for the codelessOnePage function. I’m thinking that if current-menu-item was changed to something not already used by WordPress, then this problem would go away.
-
Also, I was able to get around this issue for now by commenting out an if statement in jquery.onepage.js. This was meant to prevent you from clicking on a section you were already on, but that was killing the nav on page load since all links had the current class.
// if(!$parent.hasClass(self.config.currentClass)) {
….
//}
-
-
You must be logged in to reply to this topic.