• I’ve installed https://www.ads-software.com/plugins/amp/ plugin as well as https://www.ads-software.com/plugins/glue-for-yoast-seo-amp/ (since I’m using Yoast).

    The website works and looks fine in AMP version, passes the https://search.google.com/test/amp Google AMP test.

    However, main menu won’t work in AMP version when it’s shown on a narrow screen (mobile, or narrowed down desktop browser) – when it gets “compressed” to show just “Menu” with a dropdown button.

    Non amp page version – works fine in any screen resolution

    /6892/unior-modular-toolset/?amp AMP page version – menu doesn’t work on screen resolution that’s below about 700 pixels.

    I suppose AMP disables JavaScript, that is probably the cause. Is there a PHP work around this – so when a page address ends with “/?amp” the menu links just to the home page, or is not shown, or even works as it does in the non-amp version?

    Thanks in advance for any help, or advice.

    The page I need help with: [log in to see the link]

Viewing 6 replies - 16 through 21 (of 21 total)
  • Theme Author Tom

    (@edge22)

    I’ve published the start of the plugin, which fixes issues with the main mobile menu within AMP: https://github.com/tomusborne/amp-for-generatepress

    It’s very new, so it likely has some bugs. Worth trying though ??

    OK, didn’t get the time to work on this fast enough, but today was the day. ?? In case it hepls anyone else:

    I’ve managed to make a nicely working solution (as far as I could test, any corrections are more than welcome) by editing child theme functions.php, to show a “Menu” that just leads to the current page non-amp version (saying “HOME MENU” and being clickable, looking like a “regular menu”). Code:

    // AMP page custom menu
    
    add_action( 'generate_before_header', function() {
        if ( function_exists( 'is_amp_endpoint' ) && is_amp_endpoint() ) {
            //echo 'USING AMP ;
    		echo "<style> #site-navigation {display: none !important;} #site-navigation-navmenu2home {display: block !important;}</style>";
        }
    } );
    
    add_action( 'generate_after_header', 'navmenu2home' );
    function navmenu2home(){
         ?>
            <nav id="site-navigation-navmenu2home" class="main-navigation" style="text-align: center;vertical-align: middle;line-height: 60px;height:60px; display:none;">
    <a href="<?php the_permalink() ?>"><span style="color: white !important;">☰ HOME MENU </span></a>
    </nav>
        <?php  
    }
    
    // AMP page custom menu END

    Example pages:

    ORIGINAL:
    https://io.bikegremlin.com/7100/amp-wordpress/

    AMP:
    https://io.bikegremlin.com/7100/amp-wordpress/?amp

    Is there any reason why this is not a good solution (speed, safety, look on some exotic appliances)?

    Problems with this solution:
    1)
    Couldn’t figure out how to “get” the menu text colour, so it is defined “manually”:
    <span style=”color: white !important;”>

    2)
    The menu bar spans across the entire screen width (which is not at all important/relevant since AMP versions will only be displayed on narrower smartphone screens, but I suppose using a different hook might solve the problem – need some more “head bashing” ?? on that ).

    P.S. I hope a new Generatepress update solves this “systematically”, without needing any DIY. I understand you have many other development priorities to work on, but hoping this is among those. ??

    Theme Author Tom

    (@edge22)

    Hi there,

    Did you try the plugin I mentioned above? It should solve all issues using core GP methods without any issues ??

    Will give it a try in the following days.
    Trying to keep plugin count at a minimum as much as possible. ??

    @edge22 Tom, I was messing about with the free theme of yours a few months ago and got the mobile menu working with AMP.

    Now I’ve just purchased the premium version and I can’t remember how I got it to work and the tester site I used has been deleted.

    Have you come up with a solution yet?

    Thanks,

    David

    Theme Author Tom

    (@edge22)

    Hi David,

    Does it still work if you disable the premium theme?

    Just to confirm, are you using this plugin?: https://www.ads-software.com/support/topic/main-drop-down-menu-wont-work-with-amp/page/2/#post-11332880

    Let me know ??

Viewing 6 replies - 16 through 21 (of 21 total)
  • The topic ‘Main drop-down menu won’t work with AMP’ is closed to new replies.