プロジェクト全体がここにあります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');
お返事ありがとうございますが、私の技術ははるかに優れています。 正直なところ、あなたが話していることを完全に理解していない。 私の制限のために申し訳ありません。 ここに何らかの助けがあるかもしれないなら、その機能の参考資料:https://developer.wordpress.org/reference/functions/wp_nav_menu/ –