How to Toggle Open Your WPtouch Menu on the Front Page

Per client request I was asked that the WPtouch menu default to toggled open when on the frontpage . There may be more elegant solutions, but in order to achieve this I ended up editing a single WPtouch plugin file. If you’re going to do this make sure your code is in version control so that you can easily identify and add back the changes after any plugin update.

Now, to update WPtouch to start with an expanded menu on your homepage/frontpage open header.php for the WPtouch theme that you are using. In my case:

themes/classic/iphone/header.php

Around line 64 is the menu containing div id, id=”main-menu”:

<!-- This brings in menu.php // remove it and the whole menu won't show at all -->
            <?php if ( wptouch_has_menu() ) { ?>
                <div id="main-menu" class="closed">
                    <!-- The Hidden Search Bar -->

What you’ll want to do is add an if statement checking for is_front_page and if true you’ll go ahead and add a style to display, style=”display: block;”:

<!-- This brings in menu.php // remove it and the whole menu won't show at all -->
            <?php if ( wptouch_has_menu() ) { ?>
                <?php if ( is_front_page() ) : ?>
                <div id="main-menu" class="closed" style="display: block;">
                <?php else : ?>
                <div id="main-menu" class="closed">
                <?php endif; ?>
                    <!-- The Hidden Search Bar -->

That should do it.

Editing header.php of your chosen WPtouch mobile theme as seen above should get you an expanded menu (if you’re using the menu) on front-page visits.

Post written by Ed Reckers

Founder and lead web development consultant at Red Bridge Internet : San Francisco WordPress Developers and Consultants.

5 Responses to “How to Toggle Open Your WPtouch Menu on the Front Page”

  1. DD

    Dude – MONEY! I tried doing it myself but total fail.

  2. Josh

    HMMM, not working for me either. Im using wptouch Pro, but still have the same starting menu code you have.

  3. Josh

    NM, I got it, for some reason, the FTP app was not actually uploading it.
    I needed it to show up on all pages so I just created a css setting for instead of having to modify the php file

    #main-menu {
    display: block;
    }

    But how would I get it to push the content below the menu, I mean not having the menu be a drop down but more like a slide menu?

  4. Wade

    I opened header.php in the public_html/wp-content/plugins/wptouch/themes/default directory and the above lines of code aren’t in there.
    Am I looking in the wrong spot or has wptouch changed the way this can be done?

    Thanks…

  5. Ed Reckers

    What version of WPtouch are you using?

Leave a Reply