You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

WordPress移动端菜单无法点击求助(已尝试主流方案未解决)

Troubleshooting Mobile Menu Not Clickable in WordPress 4.9.5

Hey there, let's work through this mobile menu issue you're hitting with WordPress 4.9.5. Since you've already ruled out plugin conflicts and checked the TwentyEleven theme scripts, here are some targeted steps to narrow down and fix the problem:

  • Verify the Mobile Menu Trigger Script
    TwentyEleven's mobile menu relies on JavaScript to toggle the display property of the menu <ul>. It's possible the update disrupted this script, or it was accidentally modified.

    1. Open your theme's header.php file and check for a click handler on the menu toggle button (usually with class menu-toggle). If it's missing, add this basic toggle logic:
      jQuery(document).ready(function($) {
        $('.menu-toggle').on('click', function() {
          $('#access ul').toggle(); // Replace with your menu ul's actual selector if needed
        });
      });
      
    2. Double-check functions.php to ensure the navigation script is properly enqueued. Look for a line like this:
      wp_enqueue_script('twentyeleven-navigation', get_template_directory_uri() . '/js/navigation.js', array('jquery'), '20120206', true);
      
      If the path is incorrect or the script isn't loading, update the URI to match your theme's file structure.
  • Fix CSS Priority Conflicts
    Sometimes even with working JS, overly specific CSS rules can keep the menu hidden. Try adding these custom styles to your theme's Additional CSS section or style.css:

    /* Default state: hide mobile menu */
    #access ul {
      display: none !important;
    }
    /* Active state: show menu when toggle is clicked */
    #access ul.mobile-menu-active {
      display: block !important;
    }
    

    Then adjust the JS to toggle an active class instead of directly changing display:

    jQuery(document).ready(function($) {
      $('.menu-toggle').on('click', function() {
        $('#access ul').toggleClass('mobile-menu-active');
      });
    });
    
  • Check Menu Assignment & Hook Compatibility
    WordPress 4.9.x made minor tweaks to menu hooks. Confirm your menu is assigned correctly:

    1. Go to Appearance > Menus in your WP admin and ensure your menu is set to the "Primary" theme location (or the location your theme uses).
    2. In header.php, verify the wp_nav_menu call uses the correct theme_location:
      <?php wp_nav_menu( array( 'theme_location' => 'primary', 'menu_class' => 'nav-menu' ) ); ?>
      
  • Clear Caches to Rule Out Stale Files
    Old cached JS/CSS files can prevent new fixes from taking effect. Try:

    • Clearing your browser's cache and testing in incognito mode.
    • If you use a CDN or caching plugin, flush its cache completely.
    • For quick testing, add a dynamic version number to your enqueued script to force a refresh:
      wp_enqueue_script('twentyeleven-navigation', get_template_directory_uri() . '/js/navigation.js', array('jquery'), time(), true);
      
      (Remember to revert to a fixed version number once the issue is resolved.)

Give these steps a shot—if none resolve the problem, we can dive deeper into your theme's specific code. Hope this helps!

内容的提问来源于stack exchange,提问作者Khushbu Vaghela

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.26 10:01:05