正确注册导航菜单-WordPress

时间:2018-10-27 15:19:46

标签: php html wordpress

我花了很长时间试图为WordPress找到一个插件,该插件提供了我一直在寻找的导航菜单功能,但无济于事。 然后,我使用在Codepen和其他站点上找到的模板来创建自己的模板。

菜单的简化版本:

<nav class="content">
    <ul class="exo-menu">
        <li class="active menhome"><a href="/" class="menhme"><i class="glyphicon glyphicon-home"></i> Home</a></li>
        <li class="mega-drop-down"><a href="#" onclick="return false"><i class="fa"></i> Brands</a>
            <div id="wrapper" class="animated fadeIn mega-menu hidden">
                <div class="mega-menu-wrap">
                    <div class="row">
                        <div class="container-fluid">
                        <!-- Tab panes -->
                            <div class="tab-content">
                                <div class="tab-pane active" id="Featured">
                                    <ul class="nav-list list-inline list-inline2">
                                        <li><a data-filter=".89" href="/brand/brand-1/"><img src="https://www.example.com" alt="img"><span></span></a></li>
                                        <li><a data-filter=".97" href="/brand/brand-2/"><img src="https://www.example.com" alt="img"><span></span></a></li>
                                        <li><a data-filter=".96" href="/brand/brand-3/"><img src="https://www.example.com" alt="img"<span></span></a></li>
                                        <li><a data-filter=".85" href="/brand/brand-4/"><img src="https://www.example.com" alt="img"><span></span></a></li>
                                    </ul>
                                </div>
                                <div class="tab-pane" id="AtoF">
                                    <ul class="nav-list list-inline col-md-2">                                
                                        <li><a href="/brand/brand-a/"><span>BRAND A</span></a></li>
                                        <li><a href="/brand/brand-b/"><span>BRAND B</span></a></li>
                                        <li><a href="/brand/brand-c/"><span>BRAND C</span></a></li>
                                        <li><a href="/brand/brand-d/"><span>BRAND D</span></a></li>
                                        <li><a href="/brand/brand-e/"><span>BRAND E</span></a></li>
                                        <li><a href="/brand/brand-f/"><span>BRAND F</span></a></li>
                                    </ul>
                                </div>
                                <div class="tab-pane" id="GtoN">
                                    <ul class="nav-list list-inline col-md-2">
                                        <li><a href="/brand/brand-g/"><span>BRAND G</span></a></li>
                                        <li><a href="/brand/brand-h/"><span>BRAND H</span></a></li>                                                                                                                
                                        <li><a href="/brand/brand-i/"><span>BRAND I</span></a></li>
                                        <li><a href="/brand/brand-j/"><span>BRAND J</span></a></li>
                                        <li><a href="/brand/brand-k/"><span>BRAND K</span></a></li>
                                        <li><a href="/brand/brand-l/"><span>BRAND L</span></a></li>
                                    </ul>
                                    <ul class="nav-list list-inline col-md-2">
                                        <li><a href="/brand/brand-m/"><span>BRAND M</span></a></li>                                                                                                                                                             
                                        <li><a href="/brand/brand-n/"><span>BRAND N</span></a></li>                                                                            
                                    </ul>
                                </div>
                                <div class="tab-pane" id="OtoW">
                                    <ul class="nav-list list-inline col-md-2">
                                        <li><a href="/brand/brand-o/"><span>BRAND O</span></a></li>                                                                            
                                        <li><a href="/brand/brand-p/"><span>BRAND P</span></a></li>
                                        <li><a href="/brand/brand-q/"><span>BRAND Q</span></a></li>
                                        <li><a href="/brand/brand-r/"><span>BRAND R</span></a></li>
                                        <li><a href="/brand/brand-s/"><span>BRAND S</span></a></li>
                                        <li><a href="/brand/brand-t/"><span>BRAND T</span></a></li>
                                    </ul>
                                    <ul class="nav-list list-inline col-md-2">
                                        <li><a href="/brand/brand-u/"><span>BRAND U</span></a></li>                                                                   
                                        <li><a href="/brand/brand-w/"><span>BRAND V</span></a></li>
                                        <li><a href="/brand/brand-w/"><span>BRAND W</span></a></li>
                                    </ul>                         
                                </div>
                            </div>
                        </div>
                        <!-- Nav tabs -->
                        <ul class="nav nav-tabs" role="tablist">   
                            <li   class="active change"><a href="#Featured" role="tab" data-toggle="tab">Featured</a></li>
                            <li class="change"><a href="#AtoF" role="tab" data-toggle="tab"># - F</a></li>
                            <li class="change"><a href="#GtoN" role="tab" data-toggle="tab">G - N</a></li>
                            <li class="change"><a href="#OtoW" role="tab" data-toggle="tab">O - Z</a></li>
                        </ul>
                    </div>
                </div>  
            </div>
        </li>
        <li class="mega-drop-down mega-drop-down-2"><a href="#" onclick="return false"><i class="fa"></i> CATEGORIES</a>
            <div id="wrapper2" class="animated fadeIn mega-menu mega-menu2 hidden">
                <div class="mega-menu-wrap">
                    <div class="row">
                        <div class="container-fluid">
                        <!-- Tab panes -->
                            <div class="tab-content">
                                <div class="tab-pane active">
                                    <ul class="nav-list list-inline col-lg-12">
                                        <ul class="nav-list list-inline col-md-4">
                                            <li class="dropdown-header"><a href="/product-category/a/">A</a></li>
                                        </ul>
                                        <ul class="nav-list list-inline col-md-4">
                                            <li class="dropdown-header"><a href="/product-category/b/">B</a></li>
                                            <li Class= "dropdown-info"><a href="/product-category/c/">C</a></li>
                                            <li Class= "dropdown-info"><a href="/product-category/d/">D</a></li>
                                            <li Class= "dropdown-info"><a href="/product-category//">E</a></li>
                                            <li Class= "dropdown-info"><a href="/product-category/f/">F</a></li>
                                        </ul>
                                        <ul class="nav-list list-inline col-md-4">
                                            <li class="dropdown-header"><a href="/product-category/g/">G</a></li>
                                            <li Class= "dropdown-info"><a href="/product-category/h/">H</a></li>
                                        </ul>
                                    </ul>
                                </div>    
                            </div>
                        </div>
                    </div>
                </div>  
            </div>
        </li>
        <li class="drop-down"><a href="#" onclick="return false"><i class="fa"></i> Clothing & Accessories</a>
        <!--Drop Down-->
            <ul id="wrapper3" class="drop-down-ul animated fadeIn hidden">
                <li class="flyout-right"><a href="/product-category/clothing/">Clothing</a></li>
                <li class="flyout-left"><a href="/product-category/accessories/">Accessories</a></li>
                <li id=btmtab><a href="/product-bottles/">Bottless</a></li>
            </ul>
        </li>
            <!--//End drop down-->
        </li>
        <a href="#" class="toggle-menu visible-xs-block">Menu</a>       
    </ul>
</nav>

然后我有了一些JQuery和CSS,并在菜单中添加了一些功能和样式...

在上一个主题中,我将菜单包含在标题中,如下所示:

<div class="menubar">
    <?php
        include "main-menu.php";
    ?>
</div>

我用另一个父主题(受信任的主题)创建了一个新的子主题,但这种方法不能正常工作,包括这样的主题,因为它不允许该主题的全部功能。

我已经使用以下方法注册了菜单

    <?php
    function custom_menu() {
        register_nav_menu('/content/themes/mytheme/Main-Menu/main-menu.php',__( 'Supgen Menu' ));
  }
    add_action( 'init', 'custom_menu' );
    ?>

enter image description here

如上图所示,菜单已注册为新位置。

然后我将此位置添加到我的header.php:

<div class="site-navigation centered" role="navigation">
    <div class="container">
        <a class="toggle-nav" href="javascript:void(0);"><span></span></a>
            <?php wp_nav_menu(
                array(
                    'theme_location' => '/content/themes/mytheme/Main-Menu/main-menu.php',
                    'menu_id'        => 'primary-menu',
                    'menu_class'     => 'clearfix',
                    'fallback_cb'    => 'trusted_primary_menu_fallback',
                )
            ); ?>
    </div>
</div>

菜单似乎在正确的位置注册,因为当我选择它时,它消除了在可视化定制器中添加菜单的提示。

但是问题是,尽管它正在注册为一个位置...没有菜单显示,所以我在顶部添加的代码没有包含在菜单中。

有没有人再次提出来并且知道如何对其进行排序?

0 个答案:

没有答案