Viewing 13 posts - 1 through 13 (of 13 total)
  • Author
    Posts
  • #1396352

    Hi,

    I find the link will auto add #top after click into the page, how to remove it?

    https://imgur.com/undefined

    I just want the original links of menu

    #1396354
    #1396683

    Hi,
    Thanks for your patience, Try adding this code to the end of your child theme functions.php file in Appearance ▸ Editor:

    function custom_script() { ?>
      <script>
    (function($){
      var currentURL = document.URL;
      $('#avia-menu').each(function(){
      	$(this).find('.current-menu-item a').attr('href','');
      	setTimeout(function() {
      	$(this).find('.current-menu-item a').attr('href',currentURL);
      	}, 50);
      });
    })(jQuery);
    </script>
      <?php
    }
    add_action('wp_footer', 'custom_script');

    This gets the current URL and then removes the href attribute from the current menu item for the page and then adds the current URL that it got on the page load.
    It may look like the current menu item is missing the URL in the source code, but if you hover over the menu item or click it you will see that it still works, I don’t know why it’s not showing in the source code but it seems to be working.

    Best regards,
    Mike

    #1396701

    Hi

    missing the URL in the source code is not good, I find a post with same problem:

    Nikko have solved the problem in the post, but he didn’t say how to do it :(

    Could you let him to give the method?

    #1396711

    Hi yundian,

    Please try to edit this file: enfold/includes/helper-main-menu.php and remove this line of code (line 198).

    'theme_location'	=> $avia_theme_location,

    See if this helps.

    Best regards,
    Nikko

    #1396712

    Hi, it not work

    Remove the code, the menu will be lost

    #1396722

    Hi yundian,

    Can you provide a staging site? so we can check further.

    Best regards,
    Nikko

    #1396738

    Please use the test website i gave you in the past.

    You updated the verison to 5.4 last time, please turn it back to 4.7.6.4 same as my current site.

    Also, please check my another problem together: https://kriesi.at/support/topic/how-to-add-schema-data-in-post-time/

    many thanks

    #1396777

    Hi,
    Please follow these steps to remove the #top from being added to your current page menu links,
    Add this code to the end of your child theme functions.php file in Appearance ▸ Editor:

    function wp_change_aviajs() {
    	wp_dequeue_script( 'avia-default', $template_url.'/js/avia.js', array('jquery'));
    	wp_deregister_script(  'avia-default', $template_url.'/js/avia.js', array('jquery'));
    	wp_enqueue_script( 'avia-default', get_stylesheet_directory_uri().'/js/avia.js', array('jquery'));
    	
    	}
    	add_action( 'wp_enqueue_scripts', 'wp_change_aviajs', 100 );

    Then in your child theme directory add the directory js via FTP and add this file inside the js directory.
    Then clear your browser cache and any cache plugin, and check.
    You may need to clear the cache a few times.

    For anyone interested, in /enfold/js/avia.js on line 276 (v5.4) find:
    matching_link = this.$body.find(this.selector + "[href='"+current+"']").attr('href',current+'#top');
    and change to:
    matching_link = this.$body.find(this.selector + "[href='"+current+"']").attr('href',current);

    Best regards,
    Mike

    #1396818

    Hi Mike,

    If there is same simple way for 4.7.6.4? just like:
    ——————–
    For anyone interested, in /enfold/js/avia.js on line 276 (v5.4) find:
    matching_link = this.$body.find(this.selector + “[href='”+current+”‘]”).attr(‘href’,current+’#top’);
    and change to:
    matching_link = this.$body.find(this.selector + “[href='”+current+”‘]”).attr(‘href’,current);
    ——————–

    I have attached test website above, have done a lot changes in currunt site, can’t update in short time.

    #1396839

    Hi,
    For v4.7.6.4 you can search for the line in /enfold/js/avia.js
    matching_link = this.$body.find(this.selector + "[href='"+current+"']").attr('href',current+'#top');
    and change to:
    matching_link = this.$body.find(this.selector + "[href='"+current+"']").attr('href',current);
    but I recommend updating to v5.4 because v4.7.6.4 had some bugs for example compatibility with PHP v8 didn’t occur until v4.8, there was a pagination bug, ect.
    See our change log for v4.8 and all of the bugs for v4.7.6.4 that were fixed.
    Plus many features have been added since v4.7.6.4.
    You really should make time to add update your site to avoid future issues.

    Best regards,
    Mike

    #1396907

    Thanks, please close.

    #1396921

    Hi,

    Glad to know that this has been resolved. Please let us know if you have more questions about the theme.

    Have a nice day.

    Best regards,
    Ismael

Viewing 13 posts - 1 through 13 (of 13 total)
  • The topic ‘How to remove #top in menu link’ is closed to new replies.