-
AuthorPosts
-
February 2, 2023 at 9:46 am #1396352
Hi,
I find the link will auto add #top after click into the page, how to remove it?
I just want the original links of menu
February 2, 2023 at 9:46 am #1396354February 4, 2023 at 9:49 pm #1396683Hi,
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,
MikeFebruary 5, 2023 at 3:04 am #1396701Hi
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?
February 5, 2023 at 9:12 am #1396711Hi 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,
NikkoFebruary 5, 2023 at 9:24 am #1396712Hi, it not work
Remove the code, the menu will be lost
February 5, 2023 at 11:54 am #1396722Hi yundian,
Can you provide a staging site? so we can check further.
Best regards,
NikkoFebruary 5, 2023 at 1:37 pm #1396738Please 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
February 5, 2023 at 7:02 pm #1396777Hi,
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,
MikeFebruary 6, 2023 at 3:20 am #1396818Hi 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.
February 6, 2023 at 12:50 pm #1396839Hi,
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,
MikeFebruary 7, 2023 at 3:52 am #1396907Thanks, please close.
February 7, 2023 at 5:57 am #1396921 -
AuthorPosts
- The topic ‘How to remove #top in menu link’ is closed to new replies.