Current state child pages (in folder) not working

I had this problem regarding the current state not working properly before and I was offered a working solution by @samliew regarding the current state of sub-pages.

 <script>
 var Webflow = Webflow || [];
 Webflow.push(function() {
 var curUrl = location.pathname;
 $('a').each(function() {
 $(this).toggleClass('w--current', curUrl.indexOf($(this).attr('href')) != -1);
 });
 });
 </script>

Due to the change of the site structure the code doesn’t work anymore (applies for the Webflow hosted version of site as wall as for the website - same structure - hosted on Hostgator). Maybe someone can help me out with adjusting the js code posted above. Please see screenshots of current site structure as an attachment

Welcome to the Webflow forum!!!

Could you please edit your post Screenshot_2017-08-16_140811 and provide ALL the necessary details in your post so we can take a look at your site/issue?

If you want faster replies and more accurate answers, it is recommended that you put in a bit more effort to include all the details listed in this link, so that forum members don’t have to waste time following up with you to request more information.

Hope to hear from you soon. Thanks!

Thank you for your reply.

Unfortunately it is not always possible to share a link to the public. Simply because of privacy reasons. That’s why I took the effort to create screenshots… However, the next time I have a question I will share the site - if possible of course! Also, I tried to delete this thread because it was no longer valid.

Back to the topic. Your code (see beginning of thread) actually does work - but only in the Webflow environment and not if the site is hosted elsewhere. The solution to this problem is to apply a combo class to the sub-pages in question:

<style type="text/css"> 
.nav-link.nav-link-combo  {color: #ff0099;}
</style> 

(Found this in the forum, but can’t remember where. Did credit the person though)

1 Like