Navigation
This is archived content. Visit our new forum.

Tagged: 

  • Author
    Posts
  • #1385802
    armintz
    Participant

    I’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

    #1385952
    Christopher
    Moderator

    Hi there,

    Yes, you can add JS code under Customizer/custom/global javascript.

    Thanks.

    #1386474
    armintz
    Participant

    Neither one of the JS codes in my first post are working, that’s the reason for my post.

    #1386662
    Nico
    Moderator

    Hi 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.

    #1386728
    armintz
    Participant
    This reply has been marked as private.
    #1386857
    Lely
    Moderator

    Hi 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.

    #1386880
    armintz
    Participant

    Thanks 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.

    #1387049
    Paul R
    Moderator

    Hi,

    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.

    #1387586
    armintz
    Participant

    Close.

    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

    #1388265
    Lely
    Moderator

    Hi 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.

    #1388287
    armintz
    Participant

    Perfect – thank you!

    #1388552
    Thai
    Moderator

    You’re most welcome 🙂

  • <script> jQuery(function($){ $("#no-reply-1385802 .bbp-template-notice, .bbp-no-topic .bbp-template-notice").removeClass('bbp-template-notice'); }); </script>