Tagged: x
-
AuthorPosts
-
February 25, 2017 at 7:08 pm #1385802
armintzParticipantI’m trying to link my main logo to a custom URL instead of the home page (specifically, below the top/intro video on my home page). I have this working good in the navmenu’s “Home” link by setting up the appropriate one page + primary menus to a custom ID i’ve created.
For the logo, I’ve tried the following without success:
jQuery( document ).ready(function($) { $( ".x-brand" ).attr( "href", "URL HERE" ); });and
jQuery('.x-brand').attr('href', 'URL HERE');Is this still possible using JS or do I need to hack via child theme file ala:
https://community.theme.co/forums/topic/logo-in-header-link/site: http://tinyurl.com/joptyh4
thanks
February 26, 2017 at 1:10 am #1385952
ChristopherModeratorHi there,
Yes, you can add JS code under Customizer/custom/global javascript.
Thanks.
February 26, 2017 at 4:25 pm #1386474
armintzParticipantNeither one of the JS codes in my first post are working, that’s the reason for my post.
February 26, 2017 at 7:49 pm #1386662
NicoModeratorHi There,
In this case, please share us your admin credentials so we could check your setup further.
Don’t forget to set it as private reply.
Thanks.
February 26, 2017 at 9:00 pm #1386728
armintzParticipantThis reply has been marked as private.February 26, 2017 at 11:26 pm #1386857
LelyModeratorHi There,
There is JS error. Please look for this part on your custom JS:
jQuery(function(){ jQuery('ul.sub-menu li.current-menu-item').parents('li.menu-item-has-children').addClass('current-menu-item'); })Update to this:
jQuery( document ).ready(function($) { $('ul.sub-menu li.current-menu-item').parents('li.menu-item-has-children').addClass('current-menu-item'); });Hope this helps.
February 26, 2017 at 11:51 pm #1386880
armintzParticipantThanks for pointing out the bad js. I’ve corrected it and added the original JS code from my first post:
jQuery( document ).ready(function($) { $( ".x-brand" ).attr( "href", "URL HERE" ); });It mostly works now, but how come when you click the logo in the nav menu on the home page it behaves differently than if you click the logo on every other page? What I mean is if you click it on the home page it jumps downward, bringing the user lower on the page… not a big deal but would prefer it functioned seamlessly across the board.
Thank you.
February 27, 2017 at 4:56 am #1387049
Paul RModeratorHi,
You can add this under Custom > Edit Global Javascript in the Customizer.
jQuery(document).ready(function($) { var adminbarHeight = $('#wpadminbar').outerHeight(); var navbarFixedTopHeight = $('.x-navbar-fixed-top-active .x-navbar').outerHeight(); $('a.x-brand.img').on('touchend click', function(e) { e.preventDefault(); $('html, body').animate({ scrollTop: $('#main').offset().top - adminbarHeight - navbarFixedTopHeight + 1 }, 100, 'linear'); }); });Hope that helps.
February 27, 2017 at 11:54 am #1387586
armintzParticipantClose.
Your last code does in fact fix the home page issue that I mentioned in my previous post (the issue of clicking the home link in the navmenu on the home page bringing the user downward on the page)…
However, adding this code also seems to prevent the logo in the navmenu from taking the user to the home page when it’s clicked on all other pages on the site. For example, if you go to the ‘About’ page (or any page other than the home page), the logo doesn’t do anything when clicked.
I’ve left the code from your previous post in place so you can see the behavior on the live site, which you should still have access to (post #1386728).
Thanks
February 27, 2017 at 10:59 pm #1388265
LelyModeratorHi There,
Please try updating the code to this:
jQuery(document).ready(function($) { var adminbarHeight = $('#wpadminbar').outerHeight(); var navbarFixedTopHeight = $('.x-navbar-fixed-top-active .x-navbar').outerHeight(); $('.home a.x-brand.img').on('touchend click', function(e) { e.preventDefault(); $('html, body').animate({ scrollTop: $('#main').offset().top - adminbarHeight - navbarFixedTopHeight + 1 }, 100, 'linear'); }); });Hope this helps.
February 27, 2017 at 11:25 pm #1388287
armintzParticipantPerfect – thank you!
February 28, 2017 at 4:56 am #1388552
ThaiModeratorYou’re most welcome 🙂
-
AuthorPosts
- <script> jQuery(function($){ $("#no-reply-1385802 .bbp-template-notice, .bbp-no-topic .bbp-template-notice").removeClass('bbp-template-notice'); }); </script>
