2017-07-09 5 views
0

プロジェクト全体がここにありますGithubダイナミックメニューにCSSクラスを適用できません

ヘッダーに配置されたナビゲーションバーにダイナミックメニューを追加しました。何らかの理由で、私はstyle.cssファイルで定義されたクラスまたはIDのいずれかとダイナミックメニューをリンクする方法を理解できません。

何らかの理由で、 'menu_class'も 'menu_id'も動作していないようです。ここで

header.phpのファイル内のメニュー:

<!-- Collect the nav links, forms, and other content for toggling --> 
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1"> 
    <!--Container of my link that are on the far right, they collapse with a small screen--> 
    <ul class="nav navbar-nav navbar-right"> 
     <!--This code inject the dynamic menu inside thge av bar--> 
     <!-- The Dynamic menu is managed in the admin section of word press--> 
     <?php 
      wp_nav_menu( 
       array(
        /*must have this link to function.php 
        *In function.php we defined this menu 'alphamenu'*/ 
        'theme_location' => 'top-right-menu', 
        /*this line of code removes the default menu appearence*/ 
        'container'  => false, 
        /*this line makes the menu with the same layout specified above 
        *(same as link 1 and 2)*/ 
        'items_wrap'  => '%3$s', 
        /*CSS class applied to the menu*/ 
        'menu_class'  => 'nav navbar-nav custom-head-foot', 
        'menu_id'  => 'custom-dynamic-menu' 
       ) 
      ); 
     ?> 
    </ul> <!--dynamic menu unordered list--> 
</div> <!--dynamic menu div--> 

function.phpファイル:

/*Function to register a custom menu for the admin section 
*This resurces was taken from the wordpress codex*/ 
function custom_theme_setup() { 

    /*Registered a custom primary navigation menu*/ 
    register_nav_menus (
     array('alphamenu', __('Primary Menu 123')) 
    ); 

    /*Add theme support for title tag*/ 
    add_theme_support('title-tag'); 
} 
/*Hooking in the function "custom_theme_setup()" after the theme is setup 
*surce: wordpress plugin api hooks*/ 
add_action('after_setup_theme', 'custom_theme_setup'); 

答えて

0

renderメソッドは、あなたが常に擬似の有無にかかわらず.nav > divを使用することができます台無しにされた場合:nth-of-type(1)のようにするか、または2番目の方法があります。内の最初の子のクエリとして.nav:nth-child(1) wp_nav_menu( array( /*must have this link to function.php *In function.php we defined this menu 'alphamenu'*/ 'theme_location' => 'top-right-menu', /*this line of code removes the default menu appearence*/ 'container' => false, /*this line makes the menu with the same layout specified above *(same as link 1 and 2)*/ 'items_wrap' => '%3$s', /*CSS class applied to the menu*/ 'menu_class' => 'nav navbar-nav custom-head-foot **add_your_class_within_single_quotes**', 'menu_id' => 'custom-dynamic-menu' ) );

をか、私はあなたのCSSに最初の回答に書いたセレクタを適用することができます:あなたは、クラスを追加したい場合は

+0

お返事ありがとうございますが、私の技術ははるかに優れています。 正直なところ、あなたが話していることを完全に理解していない。 私の制限のために申し訳ありません。 ここに何らかの助けがあるかもしれないなら、その機能の参考資料:https://developer.wordpress.org/reference/functions/wp_nav_menu/ –

0

、あなたはこのように書きました)(wp_nav_menu以内にそれを追加してみてください。

関連する問題