$conf, $runtime; function_exists('chdir') AND chdir(APP_PATH); $r = 'mysql' == $conf['cache']['type'] ? website_set('runtime', $runtime) : cache_set('runtime', $runtime); } function runtime_truncate() { global $conf; 'mysql' == $conf['cache']['type'] ? website_set('runtime', '') : cache_delete('runtime'); } register_shutdown_function('runtime_save'); ?>theme development - Menu is in Reversed order|Programmer puzzle solving
最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

theme development - Menu is in Reversed order

matteradmin11PV0评论

I cannot seem to figure out why this menu is in reversed order only for Mobile.

site-navbar.php

<div class="menu-container">
    <div class="menu w-full mx-auto container xl:pr-16">
        <?php
        if (wp_is_mobile()) {
            wp_nav_menu( array( 'menu' => 'nav' ) );
        } else {
            wp_nav_menu( array( 'menu' => 'nav' ) );
        }
        ?>
    </div>
</div>

nav.php

class WalkerNav extends Walker_Nav_Menu {

    function start_lvl( &$output, $depth = 1, $args = array() ) {
        $indent = str_repeat("\t", $depth);
        $output .= "\n$indent<ul class='sub-menu'><div id='megatron'>\n";
    }
    function end_lvl( &$output, $depth = 0, $args = array() ) {
        $indent = str_repeat("\t", $depth);
        $output .= "$indent</ul></div>\n";
    }

}

Basically, on the mobile layout, Pos 6 needs to be first like the desktop and needs to be at the top for Mobile. It is a single menu.

Any help would be much appreciated.

Regards,

Jake.

I cannot seem to figure out why this menu is in reversed order only for Mobile.

site-navbar.php

<div class="menu-container">
    <div class="menu w-full mx-auto container xl:pr-16">
        <?php
        if (wp_is_mobile()) {
            wp_nav_menu( array( 'menu' => 'nav' ) );
        } else {
            wp_nav_menu( array( 'menu' => 'nav' ) );
        }
        ?>
    </div>
</div>

nav.php

class WalkerNav extends Walker_Nav_Menu {

    function start_lvl( &$output, $depth = 1, $args = array() ) {
        $indent = str_repeat("\t", $depth);
        $output .= "\n$indent<ul class='sub-menu'><div id='megatron'>\n";
    }
    function end_lvl( &$output, $depth = 0, $args = array() ) {
        $indent = str_repeat("\t", $depth);
        $output .= "$indent</ul></div>\n";
    }

}

Basically, on the mobile layout, Pos 6 needs to be first like the desktop and needs to be at the top for Mobile. It is a single menu.

Any help would be much appreciated.

Regards,

Jake.

Share Improve this question asked Nov 6, 2018 at 2:14 HenshallHenshall 1132 silver badges12 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

It's a little bit of guessing, but...

I'm pretty sure it's just a CSS problem.

The real order of your menu items is P1, P2, P3, and so on. And thus this is the order on mobile devices.

On desktop, the order is changed, because there is float: right assigned to menu items, so they do exactly that.

The easiest way to solve it will be changing the CSS for desktop menu.

Articles related to this article

Post a comment

comment list (0)

  1. No comments so far